clik-engine API
    Preparing search index...

    Variable SteeringConst

    Steering: {
        alignment(velocity: Vec2, neighborVelocities: Vec2[]): Vec2;
        arrive(
            position: Vec2,
            target: Vec2,
            velocity: Vec2,
            maxSpeed: number,
            slowRadius?: number,
        ): Vec2;
        cohesion(
            position: Vec2,
            neighbors: Vec2[],
            velocity: Vec2,
            maxSpeed: number,
        ): Vec2;
        evade(
            position: Vec2,
            target: Vec2,
            targetVelocity: Vec2,
            velocity: Vec2,
            maxSpeed: number,
        ): Vec2;
        flee(position: Vec2, target: Vec2, velocity: Vec2, maxSpeed: number): Vec2;
        obstacleAvoidance(
            position: Vec2,
            velocity: Vec2,
            obstacles: { radius: number; x: number; y: number }[],
            detectionRange?: number,
        ): Vec2;
        pursue(
            position: Vec2,
            target: Vec2,
            targetVelocity: Vec2,
            velocity: Vec2,
            maxSpeed: number,
        ): Vec2;
        seek(position: Vec2, target: Vec2, velocity: Vec2, maxSpeed: number): Vec2;
        separation(
            position: Vec2,
            neighbors: Vec2[],
            desiredSeparation?: number,
        ): Vec2;
        wander(
            velocity: Vec2,
            wanderDistance?: number,
            wanderRadius?: number,
            wanderAngle?: number,
        ): { angle: number; force: Vec2 };
    } = ...

    Individual steering behavior functions. Each returns a force vector to apply to an entity.

    Type Declaration

    • alignment: function
    • arrive: function
      • Arrive: seek with deceleration near target

        Parameters

        • position: Vec2
        • target: Vec2
        • velocity: Vec2
        • maxSpeed: number
        • slowRadius: number = 100

        Returns Vec2

    • cohesion: function
      • Cohesion: steer toward center of mass of neighbors

        Parameters

        • position: Vec2
        • neighbors: Vec2[]
        • velocity: Vec2
        • maxSpeed: number

        Returns Vec2

    • evade: function
      • Evade: predict target's future position and flee from it

        Parameters

        • position: Vec2
        • target: Vec2
        • targetVelocity: Vec2
        • velocity: Vec2
        • maxSpeed: number

        Returns Vec2

    • flee: function
      • Flee: steer away from target at max speed

        Parameters

        • position: Vec2
        • target: Vec2
        • velocity: Vec2
        • maxSpeed: number

        Returns Vec2

    • obstacleAvoidance: function
      • Obstacle avoidance: steer away from nearest obstacle

        Parameters

        • position: Vec2
        • velocity: Vec2
        • obstacles: { radius: number; x: number; y: number }[]
        • detectionRange: number = 100

        Returns Vec2

    • pursue: function
      • Pursue: predict target's future position and seek it

        Parameters

        • position: Vec2
        • target: Vec2
        • targetVelocity: Vec2
        • velocity: Vec2
        • maxSpeed: number

        Returns Vec2

    • seek: function
    • separation: function
      • Separation: steer away from neighbors that are too close

        Parameters

        • position: Vec2
        • neighbors: Vec2[]
        • desiredSeparation: number = 50

        Returns Vec2

    • wander: function
      • Wander: gentle random steering

        Parameters

        • velocity: Vec2
        • wanderDistance: number = 50
        • wanderRadius: number = 25
        • wanderAngle: number = 0

        Returns { angle: number; force: Vec2 }