This project is read-only.

Movement and Physics

May 1, 2012 at 12:08 PM

I have created some models and applied translations as you would to the models through buttons presses and xbox controller thumb stick movements. 

GamePadState currentState = GamePad.GetState(PlayerIndex.One);
KeyboardState keys = Keyboard.GetState();

       if (currentState.IsConnected)
if (gamepadStatus.ThumbSticks.Left.Y > 0.0f || keys.IsKeyDown(Keys.Up))

                playerTransNode.Translation += Vector3.Up * 4;


            if (gamepadStatus.ThumbSticks.Left.Y < 0.0f || keys.IsKeyDown(Keys.Down))

                playerTransNode.Translation += Vector3.Down * 4;


            if (gamepadStatus.ThumbSticks.Left.X > 0.0f || keys.IsKeyDown(Keys.Right))

                playerTransNode.Translation += Vector3.Right * 4;


           if (gamepadStatus.ThumbSticks.Left.X < 0.0f || keys.IsKeyDown(Keys.Left))

                playerTransNode.Translation += Vector3.Left * 4;


This works and the models move but they do not react correctly in the physics engine, eg the models travel through each other and when the physics of them colliding kick in they roll but when I move them again they reset their position to before they collided. Now I understand this is because changing the translation is sort of like teleporting and doesn't take into account the physics. So could someone help me to add correct physical movement to the model?

I have taken a look at the Advanced Physics tutorial but it is overly complex. Any help is greatly appreciated. 

May 7, 2012 at 11:03 PM

I don't have time to provide detailed explanations, but it's possible to do. The version of Newton we currently support doesn't have that functionality (their latest release may support, but I don't know), but I know that Havok and Matali physics support what you want to do. Those functionality is supported through MataliPhysics and HavokPhysics, so please look though the code for a hint of how to do it. You should also look into their (Havok or Matali) documentation to better understand it.