Solarus quests  1.6
Quest maker's reference
Path finding movement

A path finding movement is a particular path movement where the path is calculated to reach a target. The target is a map entity (by default the hero). The movement calculates repeatedly the shortest path towards the target entity, taking into account obstacles of the map. With this type of movement, an entity is capable of finding its way in a maze.

Remarks
This type of movement computes a precise path on the map grid and avoids complex obstacles by using a sophisticated A.I. algorithm (A*). If you just need to go straight towards a target, which may be more natural for basic enemies, see the target movement type.

Methods inherited from movement

Path finding movements are particular movement objects. Therefore, they inherit all methods from the type movement.

See Methods of all movement types to know these methods.

Methods of the type path finding movement

The following methods are specific to path finding movements.

path_finding_movement:set_target(entity)

Sets the target entity of this movement.

  • entity (entity): The entity to target.

path_finding_movement:get_speed()

Returns the speed of this movement.

  • Return value (number): The speed in pixels per second.

path_finding_movement:set_speed(speed)

Sets the speed of this movement.

  • speed (number): The new speed in pixels per second.

path_finding_movement:get_angle()

Returns the angle of the current trajectory in radians.

East is 0, North is math.pi / 2, West is math.pi, South is 3 * math.pi / 2.

  • Return value (number): The angle in radians.
Remarks
If you prefer a value in a 4-direction system, see movement:get_direction4().

Events inherited from movement

Path finding movements are particular movement objects. Therefore, they inherit all events from the type movement.

See Events of all movement types to know these events.