PointClickEngine::Characters::MovementController
Inherits PointClickEngine::Core::GameConstants < Reference < Object
Handles all aspects of character movement and navigation
This class centralizes movement logic that was previously duplicated across the Character class. It provides both direct movement and pathfinding capabilities with optimized calculations.
Features
- Direct movement to target positions
- Pathfinding with waypoint navigation
- Automatic animation selection based on movement direction
- Walkable area constraint checking
- Performance optimized vector calculations
Usage
controller = MovementController.new(character)
controller.move_to(target_position)
controller.update(dt)
Constructors
Instance methods
Initiate movement along a predefined path
Sets up pathfinding movement through a series of waypoints. The character will navigate through each waypoint in sequence.
- waypoints : Array of waypoints to follow
path = scene.find_path(start, destination)
controller.move_along_path(path) if path
Initiate direct movement to a target position
Sets up direct movement (no pathfinding) to the specified target. Automatically selects appropriate walking animation and clears any existing pathfinding data.
- target : World position to move to
- use_pathfinding : Whether to use pathfinding (default: character setting)
controller.move_to(Vector2.new(200, 300))
controller.move_to(target, use_pathfinding: true)
Callback to execute when movement completes
Stop all movement immediately
Clears movement target, pathfinding data, and returns character to idle state. Executes completion callback if one was set.
Current movement target (nil if not moving)
Update movement state and position
Called every frame to process movement calculations and update character position. Handles both direct movement and pathfinding.
- dt : Delta time in seconds since last update