Reply To: Unity .lookat problems

Forum Archive Unity .lookat problems Reply To: Unity .lookat problems

#31064
Jonathan Gonzalez
Participant

    You could use MoveTowards if you wanted the car to move toward the target while looking at it. Below is how you’d use it. 

    public class Movement : MonoBehaviour {
        public Transform target;
        public float speed;
        void Update() {

            transform.LookAt (target);
            float step = speed * Time.deltaTime;
            transform.position = Vector3.MoveTowards(transform.position, target.position, step);
        }