DelayBehavior

DelayBehavior

Succeeds when delay time is reached.

Extends

Members

# delay :number

Delay in milliseconds.

Type:
  • number
Default Value:
  • 1000

# actor :Actor

The actor that is running the behavior.

Type:
  • Actor
Inherited From:

# parent :Behavior

The parent behavior in the behavior tree.

Type:
Inherited From:

# tickRate :number

The tick rate in milliseconds. If a behavior doesn't return an immediate result, it will run periodically at the frequency of the tick rate. If the tick rate is set to 0, the behavior won't tick and won't run do().

Type:
  • number
Inherited From:
Default Value:
  • 100

Methods

# init(optionsopt)

Called when the behavior is instantiated.

Parameters:
Name Type Attributes Description
options Object <optional>

Optional option object passed to set()

Inherited From:

# set(options)

Sets one or more internal properties of the behavior. The internal name of each property will be the name of the option prefaced by "_". You should define corresponding getters to access these internal properties.

    class MyBehavior extends Behavior {
        get growth() {return this._growth || 0.5};
    }

    const behavior = MyBehavior.create();
    behavior.set({growth: 2});
Parameters:
Name Type Description
options Object
Inherited From:

# do(delta)

This is where the work of the behavior actually happens. If you create your own behavior overload do. This will be called once per tick`.

Note: do will be called for for the first time at random interval less than the tick rate. (This is to prevent actors that spawn simultaneously from all processing their behaviors at the save time.) If you want something to happen instantly, put it in init instead of do.

Parameters:
Name Type Description
delta number

Time in milliseconds since the last invocation of do.

Inherited From:

# destroy()

Ends the behavior. Usually you want to report succeed or fail instead.

Inherited From:

# succeed(dataopt)

Ends the behavior and reports that it has succeeded to its parent.

Parameters:
Name Type Attributes Description
data Object <optional>

An optional data object that will be passed to the parent behavior.

Inherited From:

# fail(dataopt)

Ends the behavior and reports that it has failed to its parent.

Parameters:
Name Type Attributes Description
data Object <optional>

An optional data object that will be passed to the parent behavior.

Inherited From: