This function computes a straight-line path for the instance.


mp_linear_path(path, xgoal, ygoal, stepsize, checkall);

Argument Description
path The index of the path to be used.
xgoal The target x position.
ygoal The target y position.
stepsize The speed the instance moves in pixels per step.
checkall Whether to check for collisions with all instances (true) or just solid ones (false).

Returns: Boolean.


This function computes a straight line path from the current instance position to the point specified by the "xgoal" and "ygoal" values. It uses the indicated step size, the same as in the function mp_linear_step(). The indicated path must already exist and will be overwritten by the new path and the function will return if a complete path was found (true) or not (false). If false is returned then a path is still generated, but it will only run up to the position where the path was blocked.

Note: This function does not move the instance. It sets a path only, and you must use the Path functions for movement.


if mp_linear_path(path, obj_Player.x, obj_Player.y, 2, 0) path_start(path, 2, 0, 0);

This gets the object to check and see if there is a linear path from its current position to the position of "obj_Player". If there is then it starts the path.

Back: Motion Planning
Next: mp_linear_path_object
© Copyright YoYo Games Ltd. 2015 All Rights Reserved