Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

defineBehaviour

defineBehaviour<T>(config): Behaviour<T>

Defines a behaviour once, at module scope, and returns it, typed by its trait: it holds its props to ranges in the inspector, hands ai to the AI tree and offers it to the devtools’ Add behaviour. A trait defineTrait made keeps its own name in the dump, so a trait and its behaviour may share a name; any other trait goes in the dump under name. Define one only for a behaviour whose component adds its trait and nothing more: Add behaviour gives an entity the trait alone, so a behaviour that also needs a body or a second trait would run there without it. Two behaviours under one name throw, and so does a behaviour of a trait defineTrait did not make, under a name another trait holds, except where the game’s own module runs again and defines it anew, as a hot reload or a watched room’s restart does.

Type Parameter
T extends Trait
Parameter Type
config BehaviourConfig<T>

Behaviour<T>