Question by
strikeric11 · Sep 17, 2016 at 12:21 PM ·
movetowardsc# tutorialtouchphase
touchphase.began and Vector3.MoveTowards not working
My current code is this. It moves you to your touch location as long as you pressed slightly longer. But I want to use touchphase.began the problem is it doesn't move you to your desired destination(touch location). Any workaround with this issue?
void Update () {
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Stationary)
{
//float touchPosition = Input.GetTouch(0).position.x;
Vector3 tch = Input.GetTouch(0).position;
Vector3 vec = Camera.main.ScreenToWorldPoint(tch);
Vector3 testinglng = new Vector3(vec.x, transform.position.y, transform.position.z);
transform.position = Vector3.MoveTowards(transform.position, testinglng, 1);
}
Comment