Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
4
Question by ejessop · Jul 28, 2017 at 11:32 PM · unity 5touch controlsvirtual

How to move Cinemachine FreeLook camera with touch input?

I've recently installed Cinemachine and I am trying to use a FreeLook virtual camera. The FreeLook camera is not responding to my touch input when I run in Unity remote.

When I tried writing a script to control the virtual camera transform.position based on touch input, the virtual camera did not change position but instead stayed locked to the offset set up in the component.

Does anyone have a solution for working with touch input and Cinemachine virtual cameras?

Thank you.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image rustofelees · Oct 18, 2017 at 08:15 PM 0
Share

Did you ever figure this out?

2 Replies

· Add your reply
  • Sort: 
avatar image
9

Answer by Jean-Fabre · Mar 27, 2018 at 01:29 PM

Hi,

You need to implement the GetInputAxis delegate:

   CinemachineCore.GetInputAxis = HandleAxisInputDelegate;

here is a working Component that works, simply drop it on any GameObject in your scene:

you can also get it on the PlayMaker Ecosystem or github, more info here: https://twitter.com/JeanAtPlayMaker/status/978915559994740736

 using Cinemachine;
 using UnityEngine;
 
 
 public class CinemachineCoreGetInputTouchAxis : MonoBehaviour {
 
     public float TouchSensitivity_x = 10f;
     public float TouchSensitivity_y = 10f;
 
     // Use this for initialization
     void Start () {
         CinemachineCore.GetInputAxis = HandleAxisInputDelegate;
     }
     
     float HandleAxisInputDelegate(string axisName)
     {
         switch(axisName)
         {
 
             case "Mouse X":
 
                 if (Input.touchCount>0)
                 {
                     return Input.touches[0].deltaPosition.x / TouchSensitivity_x;
                 }else{
                     return Input.GetAxis(axisName);
                 }
 
             case "Mouse Y":
                 if (Input.touchCount > 0)
                 {
                     return Input.touches[0].deltaPosition.y / TouchSensitivity_y;
                 }
                 else
                 {
                     return Input.GetAxis(axisName);
                 }
 
             default:
                 Debug.LogError("Input <"+axisName+"> not recognyzed.",this);
                 break;
         }
 
         return 0f;
     }
 }


Bye,

Jean

Comment
Add comment · Show 10 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image K-A277 · Nov 15, 2018 at 12:25 PM 0
Share

alt text

avatar image tbriz · Jan 26, 2019 at 08:13 AM 0
Share

Dude... This is amazing. Dropped it right in and it worked. Thanks man.

avatar image ksoellch · Mar 30, 2019 at 05:28 PM 0
Share

Awesome Dude thank you so much!

avatar image EnriqueCaballero1 · Dec 21, 2019 at 04:36 AM 0
Share

this works perfectly thank you

avatar image IAmChiagozie · Jun 02, 2020 at 06:21 PM 0
Share

This works perfectly!! Can you please write the code that will not let touch pass through Ui gameobjects?

I already tried IsPointerOverGameobject(Input.GetTouch(0).fingerId) but that always evaluates to false

Show more comments
avatar image
0

Answer by ciphercodersgames · Jan 26 at 07:21 AM

You are too good

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

187 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

i want to move object only when i swipe on screen not when touch, Unity 2d Android 0 Answers

create action on touch release 1 Answer

SteamVR, Multiple Cameras/Gameviews 0 Answers

Oculus Gear VR OnApplicationPause event (Unity3d 5.0) 3 Answers

Deleting virtual buttons in vuforia unity ar. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges