Sign in to follow this  
HexDump

Rotating a player some degrees using Newton Dinamics.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this