Ace_Man

11-10-2000, 04:52 PM

I'm trying to model true 3d movement.

For example, if I'm walking on a flat ground in my 3d world, I could use:

if(GetAsyncKeyState(VK_UP)) {

x += sin(angle * (3.14 / 180)) * walkSpeed;

z += cos(angle * (3.14 / 180)) * walkSpeed;

if(GetAsyncKeyState(VK_DOWN)) {

x -= sin(angle * (3.14 / 180)) * walkSpeed;

z -= cos(angle * (3.14 / 180)) * walkSpeed;

to calculate my new X and Z positions.

This isn't the problem. In this method my "Y" value is always constant. I want to allow movement in the "Y" direction based on a "lookAround" (up and down on the Y Axis) angle I've calculated.

I can't seem to get the trig to figure out this value. I can look up, but I'm always moving forward as if I'm looking forward. I want to move in the direction the camera appears to be looking. So if I point my gun at a 45 degree angle upwards, I want the bullet to move on the proper trajectory. X,Y, and Z... Any suggestions? Thanks again...

For example, if I'm walking on a flat ground in my 3d world, I could use:

if(GetAsyncKeyState(VK_UP)) {

x += sin(angle * (3.14 / 180)) * walkSpeed;

z += cos(angle * (3.14 / 180)) * walkSpeed;

if(GetAsyncKeyState(VK_DOWN)) {

x -= sin(angle * (3.14 / 180)) * walkSpeed;

z -= cos(angle * (3.14 / 180)) * walkSpeed;

to calculate my new X and Z positions.

This isn't the problem. In this method my "Y" value is always constant. I want to allow movement in the "Y" direction based on a "lookAround" (up and down on the Y Axis) angle I've calculated.

I can't seem to get the trig to figure out this value. I can look up, but I'm always moving forward as if I'm looking forward. I want to move in the direction the camera appears to be looking. So if I point my gun at a 45 degree angle upwards, I want the bullet to move on the proper trajectory. X,Y, and Z... Any suggestions? Thanks again...