• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Strafing left and right

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

### #1Hector  Members

Posted 08 November 1999 - 12:59 AM

What is the formula to strafe left or right?
In the following code fragment, FORWARD and BACKWARD work perfectly but LEFT and RIGHT only work properly when the angle is 0, PI/2, PI, 3PI/2 or 2PI. Another thing I noticed is that when the angle is PI/4, 3PI/4, 5PI/4 or 7PI/4 and I hold down FORWARD and LEFT or BACK and RIGHT the camera strafes left and right properly. I am useing a fixed cordinate system with the camera moving parallel to the x and z plane.

switch (key)
{
< >case FORWARD:
< >cameraz -= cos(angle);
< >camerax += sin(angle);
< >glutPostRedisplay();
< >break;
< >case BACK:
< >cameraz += cos(angle);
< >camerax -= sin(angle);
< >glutPostRedisplay();
< >break;
< >case LEFT:
< >cameraz += sin(angle);
< >camerax -= cos(angle);
< >glutPostRedisplay();
< >break;
< >case RIGHT:
< >cameraz -= sin(angle);
< >camerax += cos(angle);
< >glutPostRedisplay();
< >break;
< >default:
< >break;
}

### #2MikeD  Members

Posted 08 November 1999 - 12:59 AM

What happens when it is not working properly?
In which direction does it go?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.