move_outside_solid

With this function you can tell an instance to move out of a collision with any instance flagged as solid in any direction and any number of pixels each step, with a value of -1 or 0 for the maxdist being a default 1000px, ie: GameMaker will move the instance continually up 1000 pixels until it is out of collision.

 

Syntax:

move_outside_solid(dir, maxdist);

ArgumentTypeDescription
dirRealThe direction to move in.
maxdistRealThe maximum distance the object can travel (-1 or 0 a default value of 1000 pixels).

 

Returns:

N/A

 

Example:

if (other.solid)
{
    var pdir;
    pdir = point_direction(other.x, other.y, x, y);
    move_outside_solid(pdir, -1);
}

The above code would go in a collision event and checks to see if the "other" instance in the collision is flagged as "solid". If it is, it will then move the instance out of collision.