Hi,
today I try to move an Object via Swipe on an Android 2D game.
The object should follow the finger on the display 1:1. But it does not do it.
Also the object is just allowed to move at the y-axis and not at the x-axis
Here is the Code I tried:
if (Input.touches [0].phase == TouchPhase.Moved)
{
direction = Input.touches [0].deltaPosition; //Unit Vector of change in position
//speed = Input.touches[0].deltaPosition.magnitude / Input.touches[0].deltaTime; //distance traveled divided by time elapsed
Vector2 pos2 = transform.position;
pos2.y += direction.y * Time.deltaTime;
transform.position = pos2;
}
The result is different on different deviced. I think it is the resolution that makes the differences. So is there a way to let the object exact follow the finger up and down on the screen? Thank you very much!