Hi new to android development. I want to move a sprit to the point on my screen where touched. I have managed to do that but it jumps there. I know it has something to do with time.deltatime but I can’t figure it out.
this is what I have so far.
#pragma strict
var target : Transform;
function Update () {
for( var touch : Touch in Input.touches)
{
if(touch.phase == TouchPhase.Began)
{
var ray = Camera.main.ScreenPointToRay (touch.position);
var hit: RaycastHit;
print("touched");
if(Physics.Raycast(ray, hit))
{
if(hit.collider.tag == "GameController")
{
print("has Began");
print(hit);
target.position = hit.point;
}
}
}
}
}
You need to multiply the amount you want to move by deltaTime (time between frames) in order to ensure the object moves the same amount each frame, and therefore moves smoothly.