using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using UnityEngine.InputSystem; public class DoubleTriggerAction : MonoBehaviour { public InputActionReference LeftTrigger; public InputActionReference RightTrigger; private float _currentValue = 0; private bool _visorActivated = false; public UnityEvent OnActivated = new UnityEvent(); public UnityEvent OnValueChanged = new UnityEvent(); private void Update() { if (_visorActivated) return; if (RightTrigger.action.inProgress && LeftTrigger.action.inProgress) { _currentValue = Mathf.Clamp01(_currentValue + Time.deltaTime); } else { _currentValue = Mathf.Clamp01(_currentValue - Time.deltaTime); } UpdateVisorValue(); } private void UpdateVisorValue() { OnValueChanged?.Invoke(_currentValue); if (_currentValue == 1) { ActivateVisor(); } } [ContextMenu("Debug activate")] private void ActivateVisor() { _visorActivated = true; OnActivated?.Invoke(); } }