BossLookAt.cs 760 B

12345678910111213141516171819202122232425
  1. using System;
  2. using UnityEngine;
  3. namespace Cinemachine.Examples
  4. {
  5. /// <summary>
  6. /// Simple script that makes this transform look at a target.
  7. /// </summary>
  8. public class BossLookAt : MonoBehaviour
  9. {
  10. [Tooltip("Look at this transform")]
  11. public Transform m_LookAt;
  12. [Tooltip("Lock the camera's X rotation to this value (in angles)")]
  13. public float m_RotationX = 0;
  14. [Tooltip("Lock the camera's Z rotation to this value (in angles)")]
  15. public float m_RotationZ = 0;
  16. void Update()
  17. {
  18. transform.LookAt(m_LookAt);
  19. var euler = transform.rotation.eulerAngles;
  20. transform.rotation = Quaternion.Euler(m_RotationX, euler.y, m_RotationZ);
  21. }
  22. }
  23. }