Hi, I’m recently new to Unity and touch controls, I have been following the Unity scripting API’s and found this piece of code:
// 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);
}
}
This manages what I want to achieve, the problem is, the object doesn’t accurately follow my finger, sometimes it will be too fast or sometimes it will be too slow, I would like it to stay underneath my finger at all times without straying off. The speed variable doesn’t seem to make much of a difference.
Here is a video to the problem I’m having, hopefully give people and idea of what’s wrong:
Is there a way I can accomplish this?