motion_add

Adds to the motion of the calling object the given direction and speed

Syntax:

motion_add(dir, speed);


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


Returns: N/A


Description

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


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


Back: Moving Around
Next: motion_set
© Copyright YoYo Games Ltd. 2018 All Rights Reserved