Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BTPlayer: Allow switching BT instance at runtime #183

Merged
merged 2 commits into from
Aug 4, 2024

Conversation

limbonaut
Copy link
Owner

Usage example:

@export var behavior_tree: BehaviorTree

var instance: BTInstance

@onready var bt_player: BTPlayer = $BTPlayer

func _ready() -> void:
    # Initialize behavior tree instance to be used later
    var agent: Node = self
    var scene_root: Node = bt_player.get_owner()
    var blackboard: Blackboard = behavior_tree.blackboard_plan.create_blackboard(scene_root)
    instance = behavior_tree.instantiate(agent, blackboard, bt_player)

...

func _on_some_event():
    # Switch behavior tree instance upon some event
    bt_player.set_bt_instance(instance)

Note: Code written from memory - might contain errors.

@limbonaut limbonaut added the enhancement New feature or request label Aug 4, 2024
@limbonaut limbonaut added this to the 1.2 milestone Aug 4, 2024
@limbonaut limbonaut merged commit 8b27701 into master Aug 4, 2024
16 checks passed
@limbonaut limbonaut deleted the btplayer-allow-changing-instance branch August 4, 2024 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant