# movement with respect to angle

This topic is 2685 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hello

i would like to know, after changing an object's angle to any random value, as to how do i make the object move in a straight line with respect to that angle.

##### Share on other sites
Assuming you mean in 2D, firstly construct a normal vector pointing in the direction:

vx=sin(angle);vy=cos(angle);

Then multiply this by the amount you wish to move:

vx*=step;vy*=step;

Then add these to the start position to move step units in the direction:

x+=vx;y+=vy;

##### Share on other sites
Quote:
 Original post by Aardvajkvx=sin(angle);vy=cos(angle);
Assuming the usual conventions of 0 radians/degrees corresponding to the positive x axis and positive rotations being counterclockwise, 'sin' and 'cos' should be swapped in the above.