Answers for "unity android make object folow toutch"

C#
0

unity android make object folow toutch

// Moves the object according to finger movement on the screen
 
 var speed : float = 0.1f;
 
 function Update()
 {
     if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)
     {
         
         //Get movement of the finger since the last frame
         var touchDeltaPosition : Vector2 = Input.GetTouch(0).deltaPosition;
         
         // Move object across the X and Y plane
         transform.Translate (-touchDeltaPosition.x * speed, touchDeltaPosition.y * speed, 0);
     }
 }
Posted by: Guest on October-21-2021

C# Answers by Framework

Browse Popular Code Answers by Language