Archived

This topic is now archived and is closed to further replies.

Moving forward after rotation

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


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

Share this post


Link to post
Share on other sites