Skip to content

Instantly share code, notes, and snippets.

@AlexMeesters
Created June 30, 2019 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexMeesters/306ae6b1276c18437f34bd5d09f91b10 to your computer and use it in GitHub Desktop.
Save AlexMeesters/306ae6b1276c18437f34bd5d09f91b10 to your computer and use it in GitHub Desktop.
using UnityEngine;
public class MoveTowardsExample : MonoBehaviour
{
[SerializeField] private Vector3 target = new Vector3(1, 1, 1);
[SerializeField] private float speed = 1;
private void Update()
{
// Moves the object to target position
transform.position = Vector3.MoveTowards(transform.position, target, Time.deltaTime * speed);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment