This function accelerates the instance with the given speed in the given direction.
This is the equivalent of calculating the x component and y component of the given speed in the given direction, and then adding them to hspeed and vspeed respectively.
If you wish to simply set a speed instead of accelerating gradually, use motion_set().
motion_add(dir, speed);
Argument | Type | Description |
---|---|---|
dir | Real | The added direction. |
speed | Real | The added speed. |
N/A
var pdir;
pdir = point_direction(other.x, other.y, x, y);
motion_add(pdir, other.speed);
if speed > 8 speed = 8;
The above code would be called in the collision event with another object. It adds to the direction of motion and the speed of the instance a vector based on the position and speed of the other instance involved in the collision. It then limits the speed if it goes over 8 (pixels per step).