What do you call straight forward motion?

Started by
12 comments, last by nullsquared 15 years, 10 months ago
You could use vectors as in agi_shi's example or you could simply use x and y variables if you want to keep your code as it is. Then, simply do a rotation transform on x and y based on the player's direction and add those to the current x and y values to get the new position. The vector example is more elegant but I'm _assuming_ this is closer to what you're trying to achieve.
Quit screwin' around! - Brock Samson
Advertisement
I'd probably call it move, as in moveSpeed etc. Keep it simple. :)
Quote:Original post by agi_shi
vector3 move(0, 0, 0);// every frame or soif (moveLeft) move.x += -1; // to the leftif (moveRight) move.x += 1; // to the rightif (moveForward) move.z += -1; // to the forwardif (moveBackward) move.z += 1; // to the backward// global movementvector3 movement = playerOrientation * move;// now you'll want to clear the per-frame move variablemove = vector3(0, 0, 0);


Maybe move should be called 'direction.'
Quote:Original post by Moomin
Quote:Original post by agi_shi
vector3 move(0, 0, 0);// every frame or soif (moveLeft) move.x += -1; // to the leftif (moveRight) move.x += 1; // to the rightif (moveForward) move.z += -1; // to the forwardif (moveBackward) move.z += 1; // to the backward// global movementvector3 movement = playerOrientation * move;// now you'll want to clear the per-frame move variablemove = vector3(0, 0, 0);


Maybe move should be called 'direction.'


Possibly. In my case it is never normalized, though, I treat it as the basis amount of movement for the current frame. Then it's scaled by the player speed and the delta time.

This topic is closed to new replies.

Advertisement