// Update is called once per frame void FixedUpdate() { if (!_gameState.IsFinished && ThrustDirection.axis.magnitude > 0) { if (!_gameState.Started) { _gameState.Started = true; _gameState.IsTracingPath = true; _gameState.FadeOutText(); } //get controller if (ThrustDirection.activeDevice == SteamVR_Input_Sources.RightHand) { _controller = GameObject.FindWithTag("RightController"); } else if (ThrustDirection.activeDevice == SteamVR_Input_Sources.LeftHand) { _controller = GameObject.FindWithTag("LeftController"); } if (_controller != null) { _player.AddForce(_controller.transform.forward * f_Multiplier * ThrustDirection.axis.y); _player.AddForce(_controller.transform.right * f_Multiplier * ThrustDirection.axis.x); //rotate the engine thrusters to match direction of thrust transform.localRotation = Quaternion.Euler(0, (float)(Mathf.Atan2(ThrustDirection.axis.x, ThrustDirection.axis.y) * 180 / Math.PI), 0); _gameState.ThrustActiveUpdateScore(); if (!ThrustSound.isPlaying) { ThrustSound.Play(); _particleSystem.Play(); } } } else { StopThrusters(); } }
// Update is called once per frame void FixedUpdate() { if (!_gameState.IsFinished && Thrust.axis != 0) { if (!_gameState.Started) { _gameState.Started = true; _gameState.FadeOutText(); } //get controller if (Thrust.activeDevice == SteamVR_Input_Sources.RightHand) { _controller = GameObject.FindWithTag("RightController"); } else if (Thrust.activeDevice == SteamVR_Input_Sources.LeftHand) { _controller = GameObject.FindWithTag("LeftController"); } if (_controller != null) { _player.AddForce(_controller.transform.forward * f_Multiplier * Thrust.axis); _gameState.ThrustActiveUpdateScore(); if (!ThrustSound.isPlaying) { ThrustSound.Play(); _particleSystem.Play(); } } } else { StopThrusters(); } }
public void ApplyForce(RigidBody otherBody) { otherBody.AddForce(GetForce(otherBody)); }