Hi everyone,
I am new to Unity. I am trying to touch and drag my game object to some places in the screen. But sometimes when I apply more force, the game object is escaping outside out of bounding boxes and its losing its collision property. I don’t understand why it is happening ? Can anyone please help me with this problem…??? I am creating 2D game.
Thanks in advance.
The code that I used for touch and drag is,
**function Update ()
{
if (Input.touches.Length > 0)
{
if (Input.touches[0].phase == TouchPhase.Moved)
{
var x = Input.touches[0].deltaPosition.x * Time.deltaTime;
var y = Input.touches[0].deltaPosition.y * Time.deltaTime;
transform.Translate(new Vector3(x, y, 0));
}
}
}**