private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Player") { OnButtonPressed.Invoke(); } }
private void Update() { if (AudioSettings.dspTime > windowShutTime - 0.1f) { if (!anyButtonPressed) { Debug.Log("Out of time"); } OnWindowShutEvent?.Invoke(correctButtonPressed); OnButtonPressedEvent?.Invoke(false, AudioSettings.dspTime + BEAT_INTERVAL - windowShutTime); Deactivate(); } }
void OnTriggerStay(Collider other) { if (other.name.Split('_')[0] == "MenuPointer") { Vector3 otherLocal = transform.InverseTransformPoint(other.transform.position); float pushZ = transform.localPosition.z - (_OtherTriggerEnterLocalPosition.z - otherLocal.z); float threshold = -0.005f; if (pushZ < 0 && pushZ >= threshold) { transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y, pushZ); } if (pushZ <= threshold && !_ButtonExecuted) { _ButtonExecuted = true; OnButtonPressedEvent?.Invoke(this, new ButtonXRTriggerEvent(other)); } } }
private void OnButtonPressed(KeyCode keyCode) { if (anyButtonPressed) { Debug.Log("Can't take more than one input, try to be precise"); return; } if (keyCode == requiredKeyCode) { Debug.Log("Correct Input"); OnButtonPressedEvent?.Invoke(true, AudioSettings.dspTime + BEAT_INTERVAL - windowShutTime); correctButtonPressed = true; } else { Debug.Log("Incorrect Input"); OnButtonPressedEvent?.Invoke(true, AudioSettings.dspTime + BEAT_INTERVAL - windowShutTime); correctButtonPressed = false; } anyButtonPressed = true; }
void Update() { if (Input.GetKeyDown(KeyCode.LeftArrow)) { OnButtonPressedEvent?.Invoke(KeyCode.LeftArrow); } else if (Input.GetKeyDown(KeyCode.UpArrow)) { OnButtonPressedEvent?.Invoke(KeyCode.UpArrow); } else if (Input.GetKeyDown(KeyCode.RightArrow)) { OnButtonPressedEvent?.Invoke(KeyCode.RightArrow); } else if (Input.GetKeyDown(KeyCode.DownArrow)) { OnButtonPressedEvent?.Invoke(KeyCode.DownArrow); } else if (Input.anyKeyDown) { OnButtonPressedEvent?.Invoke(KeyCode.None); } }