← Back to Docs
  • index.html
  • Clayground
  • Clayground.Character3D
  • PatrolController
  • Clayground 2025.2
  • PatrolController QML Type

    AI controller for character patrol behavior. More...

    Import Statement: import Clayground.Character3D

    Properties

    Detailed Description

    PatrolController makes a character wander randomly within a defined area. It picks random destinations, turns toward them, walks there, pauses briefly, then picks a new destination.

    Example usage:

    import Clayground.Character3D
    
    Character {
        id: npc
    }
    
    PatrolController {
        character: npc
        minX: -50
        maxX: 50
        minZ: -50
        maxZ: 50
        minIdleTime: 2000
        maxIdleTime: 5000
    }

    See also Character and CharacterController.

    Property Documentation

    arrivalThreshold : real

    Distance at which character is considered to have arrived.


    character : QtObject [required]

    The character to control (required).


    destX : real

    Current destination X coordinate.


    destZ : real

    Current destination Z coordinate.


    enabled : bool

    Whether the controller is active.


    isIdle : bool

    True when character is pausing between destinations.


    maxIdleTime : int

    Maximum idle pause duration in milliseconds.


    maxX : real

    Maximum X coordinate of patrol area.


    maxZ : real

    Maximum Z coordinate of patrol area.


    minIdleTime : int

    Minimum idle pause duration in milliseconds.


    minX : real

    Minimum X coordinate of patrol area.


    minZ : real

    Minimum Z coordinate of patrol area.


    turnSpeed : real

    Turn speed in degrees per update.


    updateInterval : int

    Update frequency in milliseconds.