motion_add


Description

This function add to the direction and a movement speed of an instance, and can be very useful for collisions and simple physics.


Syntax:

motion_add(dir, speed);

Argument Description
dir The added direction.
speed The added speed.


Returns:

N/A


Example:

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 otherinstance involved in the collision. It then limits the speed if it goes over 8 (pixels per step).