How can i rotate an ode object?


My ode object falls on his back. Because of that i can’t move it anymore. How can i rotate it at runtime so that it stands right again?

the player is almost never a real physics object in a game, except if they get caught by a explosion, in which case you loose control over the character as well and it’s usually replaced by a ragdoll or similar. if you still insist on doing it, you can team up with the scientists who are trying to get humanoid roboters walking…

(try adding a angular force?)

I actually make my player a physics object - the trick is to use a simple shape (capsule) and then calculate the relevant forces to make it move as the player intends. The good thing about doing this is you get acceleration/deceleration, slowdown when walking up ramps etc, and can still have an explosion knock the player about without them entirely losing control. The maths is complicated though, and can create all sorts of really nasty bugs, so you are probably better off doing as hypnos said. I’m just saying you can do it, and its not cutting edge or anything - just a lot of fiddly vector maths with simple physics equations.

However, returning to falling over - if the player is represented by a single body (Advisable for many reasons.) then simply reset its rotation and rotational velocity every physics step (Not every frame - you should be running ode at a fixed frame rate, independent of the game frame rate - its unstable otherwise.). You will additionally only want the physics to drive the position - keep the players rotation separate from the physics engine. If crouching is never an issue you can always represent the player by a sphere and never copy the rotation from the body to the player node - then everything becomes really easy.


my ode-object is a car and when i make an accident the car sometimes lies on his roof and then i can’t drive it anymore.
how can i turn it over again? :slight_smile:

First you need to detect when the car is flipped over in code. You can probably do this by looking at the pitch and roll values of your car.

Once you have this code working reliably (be sure to test it with crashes in multiple angles), then you need to apply forces to flip the car over. Chances are that applying a single upwards impulse to a point near the front or back of the car could do the trick. However this may be difficult to make reliable.

It may be better just to destroy your car object and reinstantiate another one in the same spot (but high enough to prevent bad penetration with the ground) but with upright rotation. Better yet might be to find a guaranteed safe spot on the road instead of using the same location (since the crash location might be on a steep hill or overhanging a wall). This should be the most reliable method, but will require more game logic and map information for the driving area.

yes, sure!.. :slight_smile: i can simply delete the old car instance and make a new one on the accidentPosition… :slight_smile: thanks for the answers!!! :slight_smile: