I''m currently working in 3D, and I am trying to allow a mesh to rotate a certain amount when the user presses left or right then if the user presses up afterward it will start moving forward in that new direction after the rotation.
The rotation works great but I''m not sure about moving forward. Does this look right?
meshx+=10*cos(ay);
meshz+=10*sin(ay);
meshx and meshz are of course the x and z values of the mesh. ay is the amount of rotation that has taken place. 10 was just the number that I was planning on it incrementing by when moving forward. I think I am close but not sure if I am right.
A CRPG in development...
Need help? Well, go FAQ yourself.
Moving forward after rotation
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi
okay I think I figured it out
seems like when I made it so I use -ay instead of positive ay it works
*shrug*
A CRPG in development...
Need help? Well, go FAQ yourself.
Edited by - Nazrix on April 24, 2001 2:11:35 AM
seems like when I made it so I use -ay instead of positive ay it works
*shrug*
A CRPG in development...
Need help? Well, go FAQ yourself.
Edited by - Nazrix on April 24, 2001 2:11:35 AM
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi
Hey Nazrix, I''m not sure of the type of game you''re making and you may already be doing this, but from the code in your message it looks like you''re calling the sin() and cos() functions every time the mesh moves foward. If this is the case, it would be more efficient to call the trig. functions only during the rotation to rotate a direction vector. Then all you have to do is add the direction vector (times the speed the mesh is moving) to the meshes position. That way the trig. funtions are not called every time the mesh moves foward. Anyway, I hope this has been some help.
<span class="smallfont">That is not dead which can eternal lieAnd with strange aeons even death may die. -- "The Nameless City" - H. P. Lovecraft</span>
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement