protected void UpdateInput() { KeyboardState currentKeyState = Keyboard.GetState(); GamePadState currentGamePadState = GamePad.GetState(PlayerIndex.One); bool engineon = false; if (currentGamePadState.IsConnected) { //rotate the model using the left thumbstick, and scale it down modelYaw -= currentGamePadState.ThumbSticks.Left.X * 0.10f; //create some velocity if the right trigger is down Vector3 modelVelocityAdd = Vector3.Zero; //findout what direction we should be thrusting using rotation modelVelocityAdd.X = -(float)Math.Sin(modelYaw); modelVelocityAdd.Z = -(float)(Math.Cos(modelYaw) * Math.Cos(modelPitch)); modelVelocityAdd.Y = (float)(Math.Cos(modelYaw) * Math.Sin(modelPitch)); //Now scale our direction by how hard the trigger is down modelVelocityAdd *= currentGamePadState.Triggers.Right; if (currentGamePadState.Triggers.Right != 0f) { engineon = true; } //finally, add this vector to our velocity //modelVelocity += modelVelocityAdd; GamePad.SetVibration(PlayerIndex.One, currentGamePadState.Triggers.Right, currentGamePadState.Triggers.Right); //In case you get lost, press A to warp back to center if (currentGamePadState.Buttons.A == ButtonState.Pressed) { //modelPosition = startPosition; //modelVelocity = Vector3.Zero; modelYaw = 0.0f; } } if (currentKeyState.IsKeyDown(Keys.A)) { BEPUutilities.Vector3 rot = physicsObject.WorldTransform.Up; physicsObject.ApplyAngularImpulse(ref rot); } if (currentKeyState.IsKeyDown(Keys.D)) { BEPUutilities.Vector3 rot = physicsObject.WorldTransform.Down; physicsObject.ApplyAngularImpulse(ref rot); } if (currentKeyState.IsKeyDown(Keys.S)) { BEPUutilities.Vector3 rot = physicsObject.WorldTransform.Right; physicsObject.ApplyAngularImpulse(ref rot); } if (currentKeyState.IsKeyDown(Keys.X)) { BEPUutilities.Vector3 rot = physicsObject.WorldTransform.Left; physicsObject.ApplyAngularImpulse(ref rot); } if (currentKeyState.IsKeyDown(Keys.Q)) { BEPUutilities.Vector3 rot = physicsObject.WorldTransform.Backward; physicsObject.ApplyAngularImpulse(ref rot); } if (currentKeyState.IsKeyDown(Keys.E)) { BEPUutilities.Vector3 rot = physicsObject.WorldTransform.Forward; physicsObject.ApplyAngularImpulse(ref rot); } if (currentKeyState.IsKeyDown(Keys.W)) { physicsObject.ApplyImpulse(physicsObject.Position, physicsObject.WorldTransform.Forward); engineon = true; } if (currentKeyState.IsKeyDown(Keys.P)) { //modelPosition = Vector3.Zero; // modelVelocity = Vector3.Zero; soundHyperSpaceActivation.Play(); } if (engineon) { if (soundEngineInstance.State == SoundState.Stopped) { soundEngineInstance.Volume = 0.75f; soundEngineInstance.IsLooped = true; soundEngineInstance.Play(); } else { soundEngineInstance.Resume(); } } else { soundEngineInstance.Pause(); } }