Strafing 3d

There is no movement on the Y plane except rotation, which is ‘heading’ below.

to strafe right I am trying:


            xpos += (float) Math.cos(heading * CubeWars.piover180) * speed;
            zpos += (float) Math.sin(heading * CubeWars.piover180) * speed;

At game launch, strfing right works, but the moment I rotate on the Y axis, strafing no longer works.
Where is my math wrong? (I was a Bio major who only took calculus in 1985, so laugh it up! :slight_smile: )

[quote]At game launch, strfing right works, but the moment I rotate on the Y axis, strafing no longer works. Where is my math wrong? (I was a Bio major who only took calculus in 1985, so laugh it up! :slight_smile: )
[/quote]
I’m just copying in the code to strafe right in Auriga3D, so you can work it take a stab at converting it for your purposes. +Z is up in Auriga3D / Quake3


/**
 *  Move the camera's position in our world.
 * The direction of movement is based on the current viewing direction.
 * moves the camera 90 degress to the right;
 *
 * @param  step  Amount to move.
 */
public final void strafeRight(float step)
{
   origin.x -= step * (float) Math.sin(yaw + STRAFERIGHT);
   origin.y += step * (float) Math.cos(yaw + STRAFERIGHT);
}

STRAFERIGHT = -90 * PIDIV180;
yaw is rotation about the Z axis

Thanks. After some tinkering, I think I have it.

M