Firstborn/Library/PackageCache/com.unity.cinemachine@2.8.9/Samples~/Cinemachine Example Scenes/Scenes/3rdPersonWithAimMode/ActivateOnKeypress.cs
Schaken-Mods b486678290 Library -Artifacts
Library -Artifacts
2023-03-28 12:24:16 -05:00

39 lines
908 B
C#

using UnityEngine;
public class ActivateOnKeypress : MonoBehaviour
{
public KeyCode ActivationKey = KeyCode.LeftControl;
public int PriorityBoostAmount = 10;
public GameObject Reticle;
Cinemachine.CinemachineVirtualCameraBase vcam;
bool boosted = false;
void Start()
{
vcam = GetComponent<Cinemachine.CinemachineVirtualCameraBase>();
}
void Update()
{
if (vcam != null)
{
if (Input.GetKey(ActivationKey))
{
if (!boosted)
{
vcam.Priority += PriorityBoostAmount;
boosted = true;
}
}
else if (boosted)
{
vcam.Priority -= PriorityBoostAmount;
boosted = false;
}
}
if (Reticle != null)
Reticle.SetActive(boosted);
}
}