Page 1 of 1

Moving body with Newton

Posted: Tue May 23, 2006 4:40 pm
by hoffhoff
Hello,
I don´t know if this is the right place to ask for this help, but anyway...


I´m using Newton engine with Irrlicht.
I have a question about the movement of the player.
When I click the button to move forward, for example, what is the right way to move:
1. Apply a force on newton body and then update the mesh position or
2. Move the mesh and then update the newton´s body
?

I tried the 1 and it works, but the movement is strange. Then I tried the 2, but then newton crashed on collisions.

So, what´s trhe right way?


Thanks!

Posted: Tue May 23, 2006 5:57 pm
by Baal Cadar
Version 2 shouldn't crash obviously, so you did something wrong there. But option 2 is not desired really, it leaves to much work for you, which a physics engine can handle better and allow a more intuitive interaction with the environment.

Actually there is a third option. To update velocity instead of applying a force.
Myself I use option 1, force application. The approach is called inverse dynamics. You determine delta of current velocity and target velocity and calculate acceleration to get there in some time frame. Simply (v0-v1)/timestep will do for a start. This will yield an acceleration a, which can be used to calculate force via F = m*a. Same way works for angular velocity. Notice, that setting a proper inertia is vital here.

For more info search Newton forum for inverse dynamics. There are heaps of useful posts.