LookAt.cs 482 B

1234567891011121314151617181920
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class LookAt : MonoBehaviour
  5. {
  6. [SerializeField] private Transform m_Target = null;
  7. Transform m_Trans = null;
  8. private void Awake() {
  9. m_Trans = transform;
  10. }
  11. // Update is called once per frame
  12. void Update() {
  13. if (m_Target == null) return;
  14. m_Trans.LookAt(m_Target);
  15. m_Trans.eulerAngles = new Vector3(0, m_Trans.eulerAngles.y, 0);
  16. }
  17. }