How do I make my AI run away from light? in Behavior Tree

I have this sphere collision that when overlapping, sends a message to the “AI controller”


the objective of overlapping is this, a sphere collision that determines the distance of my point light, which has a tag: “damage light”

the event in the AI controller determines if the component has the tag, then sets the values of the decorator and the values of the task to be executed in the behavior tree

and this is the branch, i put it as top priority so that it stops the other tasks

and this is the task:

I try to implement the same method that was used in this tutorial:


there are times when it seems to work fine but then it breaks and it seems as if it doesn’t detect overlapping anymore, it’s buggy, if there’s a better method I’d like to know

In short, that’s my problem, I don’t know if I’m making it too complicated

If necessary, I will try to prepare the project files to pass

@Hector-c5 You seem to have written light incorrectly when passing in the literal string on the picture with the circled decorator.

Could this be why a blackboard key is not being set correctly?

In set value as vector you pass in damage_ligth instead of damage_light

You could do an optimization. If you have the light position vector then you could just measure the distance between the bug and the light position and if it less than the set radius (can be a float) then you can trigger the run away ai behavior.

I think that defining the distance with a float could work better, but it means stop using overlapping, right?

I’m going to check the literal string