move_contact_solid

Moves the instance in a given direction until it comes into contact with a solid object.

Syntax:

move_contact_solid( dir, maxdist );


Argument Description
dir The direction to move in.
maxdist The maximum distance the object can travel (-1 or 0 a default value of 1000 pixels).


Returns: N/A


Description

This function will move the instance running the code a set number of pixels in the specified direction until it meets an instance with solid flagged as true. You can use -1 or 0 for the maxdist being a default 1000px, ie: GameMaker: Studio will move the instance continually up 1000 pixels until it is out of collision.


Example:

if !place_meeting(x, y + 1, obj_Floor)
   {
   move_contact_solid(270, -1);
   }

The above code will check beneath the instance for a collision with "obj_Floor", and if there is none, then it will move it down until there is a collision, or 1000 pixels have been covered.


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