-
-
Save AlexMeesters/306ae6b1276c18437f34bd5d09f91b10 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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