|
I'm working in DirectX/C++ just now. At the moment, I move things along the x and y axis and rotate them around the z axis - but I want to move the object "forward" along the heading it's been rotated to (I'm thinking asteroids - where the ship moves along the direction it's heading). Any idea/tutorials on how to do this?
|
# ¿ Dec 1, 2007 22:06 |
|
|
# ¿ Apr 27, 2024 05:03 |
|
Ugg boots posted:Just some simple vector math, really. Instead of moving the ship 1 unit in the Y direction, to move it forward just move it cos(angle) in the X direction and sin(angle) in the Y direction. If you're not keeping an angle, and your direction is in the form of a vector, just normalize that vector (let's call it V) and move Vx * speed in the X direction and Vy * speed in the Y direction. That's great, thanks! I've almost got this working with vectors (it's OK when I'm at the origin, but not when I move about, so I think I'm forgetting to multiply something somewhere). My next question then is - is there any way to get the angle you've rotated from a rotation matrix?
|
# ¿ Dec 2, 2007 20:43 |