Rotating a player some degrees using Newton Dinamics.

This topic is 3921 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

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 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 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 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).

HexDUmp.

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...

1. 1
2. 2
3. 3
4. 4
Rutin
12
5. 5

• 12
• 19
• 10
• 14
• 10
• Forum Statistics

• Total Topics
632663
• Total Posts
3007707
• Who's Online (See full list)

There are no registered users currently online

×