← Back to Docs
  • index.html
  • Clayground
  • Clayground.Behavior
  • MoveTo
  • Clayground 2025.2
  • MoveTo QML Type

    Moves an actor entity to a specified destination using physics. More...

    Import Statement: import Clayground.Behavior
    Inherits:

    Rectangle

    Properties

    Signals

    Detailed Description

    MoveTo provides physics-based movement of an entity toward a target position. It uses velocity adjustments to smoothly move the actor and detects arrival using collision sensors.

    Example usage:

    import Clayground.Behavior
    
    RectBoxBody {
        id: enemy
    
        MoveTo {
            world: theWorld
            destXWu: player.xWu
            destYWu: player.yWu
            running: true
            desiredSpeed: 3
            onArrived: console.log("Reached target!")
        }
    }

    Property Documentation

    actor : var

    The entity to move (defaults to parent).


    debug : bool

    Show debug visualization of destination.


    debugColor : color

    Color for debug visualization (default: "lightblue").


    desiredSpeed : real

    Movement speed in world units per second (default: 2).


    destXWu : real

    Destination X coordinate in world units.


    destYWu : real

    Destination Y coordinate in world units.


    running : bool

    Whether movement is active.


    world : ClayWorld2d [required]

    The world context (required).


    Signal Documentation

    arrived()

    Emitted when the actor reaches the destination.

    Note: The corresponding handler is onArrived.