Home

Published

- 1 min read

unity movetowards

img of unity movetowards

The solution for this is noted below

unity movetowards

Solution

   float speed;
Vector3 goalPosition;

void Update()
{
	transform.position = Vector3.MoveTowards(transform.position, goalPosition, speed * Time.deltaTime); //goes from the position of the gameObject to the goalPosition in a strait line with a speed of "speed"
  	//Also works with Vector2
}

Try other methods by searching on the site. That is if this doesn’t work