Moving in 3rd person
i got this model and a 3rd person view. i''ve made the model walk on a terrain and i can control it with the mouse (it''s something like Diablo). the model canl walk everywhere on the terrain but the problem is that this fuXXXing bXXch doesn''t turn left or right :°°° i''m trying to use glRotatef(angle,0,1,0) but i need the right angle.. how can i find it?
You forgot to say please!
DISCLAIMER: If any of the above statements are incorrect, feel free to deliver me a good hard slap!My games: DracMan | Swift blocks
Use glLookAt() instead. Complete information is found on www.gametutorials.com
The angle you are looking for is the angle between your player''s previous direction vector and the new one. Heres a diagram:
So lets say that you were going right so you clicked right. Your player starts to move in that direction. Then you click down, in order to rotate your player you need to find the angle between the old vector and the new vector and add it to the total of your player''s angle.
Check the net for how to find the angle between two vectors - its an extension of dot product i think.
________________________________\ \ O \ ¯T¯ old direction (previous mouse click) \ / \ -------> \ \ \ \ \ _| new direction (new mouse click) \ \__________________________________
So lets say that you were going right so you clicked right. Your player starts to move in that direction. Then you click down, in order to rotate your player you need to find the angle between the old vector and the new vector and add it to the total of your player''s angle.
Check the net for how to find the angle between two vectors - its an extension of dot product i think.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement