Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

unity movetowards

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
}
 
PREVIOUS NEXT
Tagged: #unity #movetowards
ADD COMMENT
Topic
Name
8+6 =