Moving body with Newton

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
hoffhoff
Posts: 17
Joined: Fri Mar 10, 2006 11:55 am

Moving body with Newton

Post 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!
Baal Cadar
Posts: 377
Joined: Fri Oct 28, 2005 10:28 am
Contact:

Post 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.
No offense :)
Post Reply