Rotating a player some degrees using Newton Dinamics.

Started by
3 comments, last by haphazardlynamed 16 years, 3 months ago
Hi all, I´m using Newton as my physics/collision engine. It is first tiem I use a physics engine in a game, so, I´m a bit lost. I have read in a lot of places that I shouldn´t manipulate position/orientation of the rigid bodies directly, but with forces. The problem is that when I want to do things like rotate my player 180 degrees to face in different direction when pressing left/right is pretty difficult to accomplish this way. So, Could anybody explain how should I do this?. I have seen the setTorque method for the body but it is too difficult to make it rotate 180 grees exactly. Thanks in advance, HexDump.
Advertisement
Most games use a shape such as a cylinder, or a capsule, to approximate the shape of a player in game. This shape usually has a ray protruding form the bottom to enable to enable the character to go up and down the terrain. The shape itself is then used to test if the character is "allowed" to make a particular move, and to handle falling, etc.

The actual mesh of the player can be used for bullet collisions, however.

n.b. you won't, therefore, actually need to rotate the approximation shape, since it should completely surround the player.
I just wanted to see if he would actually do it. Also, this test will rule out any problems with system services.
I had a similar issue for a spaceship type game, with figuring out the amount of torque needed to rotate the ship to face a given direction.
Tho its not truly a correct solution, it may be 'good enough' for you to try using 'PID Controllers' to adjust the torque force. Look these up, theres plenty of resources...

been a while since I used them, but I thought this page was a good overview without getting too much into the intimidating math of it http://www.embedded.com/2000/0010/0010feat3.htm
Thanks for the help. Anyway, I think I will take out my player from simulation. And and just a body that will be moved directly by hand to get collisions (the only real thing I need for my player).

Thanks in advance,
HexDUmp.
One reason to avoid moving the player character directly 'by hand' is that if for example the user is using mouse controls, then a player can 'cheat' by increasing mouse sensitivity to allow faster movement.
Also, if there are framerate/cpu speed issues, then similar issues can come up...

This topic is closed to new replies.

Advertisement