using System.Collections; using System.Collections.Generic; using UnityEngine; public class Follow : MonoBehaviour { [SerializeField] private Transform target; // Start is called before the first frame update // Update is called once per frame void Update() { Vector3 lookPos = target.position - transform.position; Quaternion lookRot = Quaternion.LookRotation(lookPos, Vector3.up); float eulerY = lookRot.eulerAngles.y; Quaternion rotation = Quaternion.Euler(0, eulerY, 0); transform.rotation = rotation; } }