[ODE] Controls

Remi Ricard remi.ricard at simlog.com
Wed Sep 6 08:45:24 MST 2006


> Hi everybody
> i'm implementing a camera, which is represented by a body in my scene. i 
> want to move the camera to left/right and bottom/up inside the scene.
> i want to make it using forces that act on the center of mass of the body. 
> The forces are result from pushing the arrows-buttons on the keyboard.
> for example when i'm holding the left arrow-button, i want that the body is 
> moving left, and stop immediately if i leave the button. But now when i'm
> applying a force, the body doesn't stop when  leave the button. I'm 
> implementing for the very first time controls, so i'll be very gratefull fo 
> every advice.
This is a result of the First Law of Newton:
If I'm moving I will keep moving if there is no force to slow me down.

It will be hard to stop it as soon as you release the button.
You can find the velocity of the body and apply a counter force to stop 
it in one time frame.
You can use the equation below where v_1 = 0   v_0 is the velocity now
Force is the force you have to find  and delta_t is the time of a frame.

v_1 = v_0 + 1/2 Force/mass delta_t^2
What You can do is to set the velocity

You can have a little bit of oscillation with this.

What you can do also is attach the body of the camera to 2 linear motor 
(at 90deg of each other) and set the speed of the
motor to a given value when you hit a key at  zero if the key is not 


More information about the ODE mailing list