init
TypeScriptstatic init(definition: ArrayBuffer): BehaviorTreeResourceSwift declarationconvenience init(definition: Data) throwsCompile a new resource from data, throws on failure.
class · iOS 27.0+ · SDK 27.1
class BehaviorTreeResourceAn immutable representation of a behavior tree. A `BehaviorTreeResource` can be produced by compiling a tree definition. Once compiled, assign it to an entity via ``BehaviorTreeComponent`` to begin driving behaviors: let treeResource1 = try BehaviorTreeResource(definition: Data(behaviorTreeDefinition1.utf8)) let treeResource2 = try BehaviorTreeResource(definition: Data(behaviorTreeDefinition2.utf8)) let treeResources: [String : BehaviorTreeResource] = ["tree1" : treeResource1, "tree2" : treeResource2] entity.components.set(BehaviorTreeComponent(behaviorTree: resource, availableBehaviorTrees: treeResources)) ## Parameters The tree exposes a set of named parameters that control its behavior at runtime, such as movement speed. Read the available parameters via ``parameterNames``. To set values at runtime, use the entity's parameter binding: entity.parameters["MoveSpeed"] = BindableValue(Float(1.0))
static init(definition: ArrayBuffer): BehaviorTreeResourceSwift declarationconvenience init(definition: Data) throwsCompile a new resource from data, throws on failure.
get parameterNames(): Array<string>Swift declarationvar parameterNames: [String] { get }Returns the names of all parameters in the behavior tree resource.
static validate(definition: ArrayBuffer): Array<string>Swift declarationstatic func validate(definition: Data) -> [String]Run the compiler and return all tree errors without producing a resource.
No declarations were skipped in this snapshot.