nikki
28-10-2006 11:32:00
Hello everybody! I have a few problems implementing a player in my game. Here is an image with a description:-
In my game, the player is a rolling ball. The camera has a third-person view of the player. To turn the player, the user uses the mouse, making it rotate around the global Y axis. To move forward, the user has to press the W key, which applies a torque making it rotate around the local X axis. There shold be no rotation at all around the Z axis, even because of the action of gravity. So, he is just like a wheel, and the wheel should never slip or slide. I have been working on this for the past few hours, with varied results. This is what I have done so far:-
- I made the contact joint between the player and another body have an infinite amount of coulomb friction.
- I wrote some code that adds torque to the player when the W key is pressed. The torque vector is multipied by the player's orientation.
This is my problem:-
- When I make the player rotate around his Y axis by getting his orientation, multiplying it by a quaternion that rotates it around the Y axis, and setting the players orientation to the resulting quaternion, the player rotates around his local Y axis.
- I haven't tried this yet, but I think that if I put the player on a slope, there is a chance of rotation around the Z axis.
How can I solve these problems? Is there a better way to make the player accelerate?
Thanks for your help.
In my game, the player is a rolling ball. The camera has a third-person view of the player. To turn the player, the user uses the mouse, making it rotate around the global Y axis. To move forward, the user has to press the W key, which applies a torque making it rotate around the local X axis. There shold be no rotation at all around the Z axis, even because of the action of gravity. So, he is just like a wheel, and the wheel should never slip or slide. I have been working on this for the past few hours, with varied results. This is what I have done so far:-
- I made the contact joint between the player and another body have an infinite amount of coulomb friction.
- I wrote some code that adds torque to the player when the W key is pressed. The torque vector is multipied by the player's orientation.
This is my problem:-
- When I make the player rotate around his Y axis by getting his orientation, multiplying it by a quaternion that rotates it around the Y axis, and setting the players orientation to the resulting quaternion, the player rotates around his local Y axis.
- I haven't tried this yet, but I think that if I put the player on a slope, there is a chance of rotation around the Z axis.
How can I solve these problems? Is there a better way to make the player accelerate?
Thanks for your help.