Closed ziengri closed 5 months ago
Well, this would be very similar to tick
wouldn't it? Because tick
basically is called when the leaf is entered.
Every time the behavior tree reaches BTRepeat, I need to write a number from _actor.rep in repetition and the same situation with LeafWait
I think it would be a better choice to actually create a Leaf that does this and put it before the BTRepeat
like this:
BTSequence
LeafWriter
BTRepeat
With LeafWriter
looking something like this:
class_name LeafWriter extends BTLeaf
@export var target: BTRepeat
func _tick(_delta: float, actor: Node, _blackboard: Blackboard):
# Adjust according to your needs. Maybe even make a generic option using more exports for more reusability.
target.repetitions= actor.reps
return BTStatus.SUCCESS
I suggest adding the _on_enter(_actor: Node) function to leaf , composite and etc. Since this will make it possible to conveniently change behaviors or parameters in them. Example:every time the behavior tree reaches BTRepeat, I need to write a number from _actor.rep in repetition and the same situation with LeafWait