void Update() { if (m_LeftController.isValid) { bool activated = false; for (int i = 0; i < m_ActivationButtons.Count; i++) { m_LeftController.IsPressed(m_ActivationButtons[i].button, out bool value, m_ActivationButtons[i].threshold); activated |= value; } bool deactivated = false; for (int i = 0; i < m_DeactivationButtons.Count; i++) { m_LeftController.IsPressed(m_DeactivationButtons[i].button, out bool value, m_DeactivationButtons[i].threshold); deactivated |= value; } if (deactivated) { m_LeftTeleportDeactivated = true; } // if we're pressing the activation buttons, we transition to Teleport if (activated && !m_LeftTeleportDeactivated) { m_LeftControllerState.SetState(ControllerStates.Teleport); if (oneActiveTeleportController && ((m_LatestActiveTeleportController && m_RightControllerState.GetState() == ControllerStates.Teleport) || (!m_LatestActiveTeleportController && !m_RightTeleportDeactivated))) { m_RightControllerState.SetState(ControllerStates.Select); m_RightTeleportDeactivated = true; } } // otherwise we're in normal state. else { m_LeftControllerState.SetState(ControllerStates.Select); if (!activated) { m_LeftTeleportDeactivated = false; } } } if (m_RightController.isValid) { bool activated = false; for (int i = 0; i < m_ActivationButtons.Count; i++) { m_RightController.IsPressed(m_ActivationButtons[i].button, out bool value, m_ActivationButtons[i].threshold); activated |= value; } bool deactivated = false; for (int i = 0; i < m_DeactivationButtons.Count; i++) { m_RightController.IsPressed(m_DeactivationButtons[i].button, out bool value, m_DeactivationButtons[i].threshold); deactivated |= value; } if (deactivated) { m_RightTeleportDeactivated = true; } if (activated && !m_RightTeleportDeactivated) { m_RightControllerState.SetState(ControllerStates.Teleport); if (oneActiveTeleportController && ((m_LatestActiveTeleportController && m_LeftControllerState.GetState() == ControllerStates.Teleport) || (!m_LatestActiveTeleportController && !m_LeftTeleportDeactivated))) { m_LeftControllerState.SetState(ControllerStates.Select); m_LeftTeleportDeactivated = true; } } else { m_RightControllerState.SetState(ControllerStates.Select); if (!activated) { m_RightTeleportDeactivated = false; } } } }
void Update() { if (m_LeftController.isValid) { bool activated = false; for (int i = 0; i < m_ActivationButtons.Count; i++) { m_LeftController.IsPressed(m_ActivationButtons[i], out bool value); if (!value && m_LeftControllerState.GetState() == ControllerStates.Teleport && m_LeftController.TryGetFeatureValue(new InputFeatureUsage <Vector2>("Primary2DAxis"), out Vector2 val)) { if (val.magnitude > m_LeftControllerState.TeleportationThreshold) { value = true; } } activated |= value; } bool deactivated = false; for (int i = 0; i < m_DeactivationButtons.Count; i++) { m_LeftController.IsPressed(m_DeactivationButtons[i], out bool value); m_LeftTeleportDeactivated |= value; } if (deactivated) { m_LeftTeleportDeactivated = true; } // if we're pressing the activation buttons, we transition to Teleport if (activated && !m_LeftTeleportDeactivated) { m_LeftControllerState.SetState(ControllerStates.Teleport); } // otherwise we're in normal state. else { m_LeftControllerState.SetState(ControllerStates.Select); if (!activated) { m_LeftTeleportDeactivated = false; } } } if (m_RightController.isValid) { bool activated = false; for (int i = 0; i < m_ActivationButtons.Count; i++) { m_RightController.IsPressed(m_ActivationButtons[i], out bool value); if (!value && m_RightControllerState.GetState() == ControllerStates.Teleport && m_RightController.TryGetFeatureValue(new InputFeatureUsage <Vector2>("Primary2DAxis"), out Vector2 val)) { if (val.magnitude > m_RightControllerState.TeleportationThreshold) { value = true; } } activated |= value; } bool deactivated = false; for (int i = 0; i < m_DeactivationButtons.Count; i++) { m_RightController.IsPressed(m_DeactivationButtons[i], out bool value); deactivated |= value; } if (deactivated) { m_RightTeleportDeactivated = true; } if (activated && !m_RightTeleportDeactivated) { m_RightControllerState.SetState(ControllerStates.Teleport); } else { m_RightControllerState.SetState(ControllerStates.Select); if (!activated) { m_RightTeleportDeactivated = false; } } } }