Firstborn/Library/PackageCache/com.unity.cinemachine@2.8.9/Samples~/Cinemachine Example Scenes/Scenes/BossCamera/BossLookAt.cs

23 lines
653 B
C#
Raw Normal View History

2023-03-28 13:24:16 -04:00
using System;
using UnityEngine;
/// <summary>
/// Simple script that makes this transform look at a target.
/// </summary>
public class BossLookAt : MonoBehaviour
{
[Tooltip("Look at this transform")]
public Transform m_LookAt;
[Tooltip("Lock the camera's X rotation to this value (in angles)")]
public float m_RotationX = 0;
[Tooltip("Lock the camera's Z rotation to this value (in angles)")]
public float m_RotationZ = 0;
void Update()
{
transform.LookAt(m_LookAt);
var euler = transform.rotation.eulerAngles;
transform.rotation = Quaternion.Euler(m_RotationX, euler.y, m_RotationZ);
}
}