#### Archived

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

# Moving forward after rotation

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

## 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 on other sites
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

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

1. 1
2. 2
3. 3
Rutin
22
4. 4
frob
18
5. 5

• 33
• 13
• 11
• 10
• 12
• ### Forum Statistics

• Total Topics
632572
• Total Posts
3007128

×