- Edited
So, I have a behavior tree that I have set up. I have a timer node in it as a ConditionLeaf. I use the same node two places in my code, one is for my enemies movement, the other is for their attack. I use @export variables so that I can change the time while using same script. One node works just fine and has a timer of 0.33 seconds, the other timer for my attack starts out at 1.0, and then when it resets it resets to 0.2, and that is what it keeps resetting to, never continuing down my behavior tree to initiate the attack.
@icon("res://icons/node_2D/icon_time.png")
extends ConditionLeaf
@export var timer_length: float
@export var current_timer: float
@export var debug_switch: bool
func tick(actor, blackboard):
if debug_switch:
return FAILURE
if not current_timer > 0:
current_timer = timer_length
return SUCCESS
current_timer -= blackboard.get_value("delta", null, actor)
return RUNNING
This is the code, this is the same code used in both places, one works, and one fails. The working one the timers are set to 0.33, the failure is 1.0. The blackboard is getting delta time stored at the top of the behavior tree.