Jump to content
  • Advertisement


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


quake movement

This topic is 6918 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

Hello I have a problem I'' tryng to implement a movement similar to quake, half-life and family, but i need help. In this case, when the player press forward or back, i make a translation of 10 or -10 while the key is pressed, and it''s all fine. When i press the left or right key to rotate, the camera also rotates in the direction that i wan''t, but she rotates as if the camera was still in the origin(0,0,0). typedef struct{ float x; float y; float z; float xrot; float yrot; float zrot; }camera; camera look; when i press forward, i add the look.x 10 units when i press back i subtract look.x 10 units when i press left, i add the angle +10; when i press right i subtract the angle -10; glLoadIdentity(); glTranslatef(look.x,look.y,look.z); glRotatef(angle,0,look.yrot,0); If i make the translation first and then the rotation, the rotation works fine, but only if i still hadn''t pressed the forward button If i press the forward button first, and then the left or right, the rotation is not correct, he rotates as if the rotation was being made at the origin. Please advice Thanks Bruno

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
You have to rotate first, then translate. All rotations happen around the origin, so if you translate before you rotate, instead of rotating in place, you make a wide arc around the origin...

Share this post

Link to post
Share on other sites
You should move the player/camera like this:

pos.x -= deltatime*speed*sin(angle);
pos.z -= deltatime*speed*cos(angle);

Then set up your modelview matrix like this


(Sorry about the short answer, but I''m tired right now.)

- WitchLord

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!