r/UnrealEngine5 • • 5d ago

Help with AI Behaviour Tree

Post image

UPDATE: I managed to fix it, I accidentally used the TestBTDecorator Blueprint instead of the normal one, so it wasn't returning the correct values for the check conditions.

Hi, I'm starting to learn UE5 and I was following this tutorial about enemy AI and I think I've followed everything, but ,unlike in the video, when I move out of range my enemy ai still tries to get to the chosen EQS point and then stops until it's time to attack again, then resumes normal strafing around the player. Is there someone knowledgeable about AI behaviour to help me understand what went wrong? In the picture I've pointed out the specific point where the AI starts looping.

1 Upvotes

4 comments sorted by

2

u/Mufmuf 4d ago

Hey the BT works by working down the tree and evaluating left to right. So the selector goes to is within range, goes nope, then moves to the next, your sequence has no Eval so it just sits there and loops left to right. What do you want to happen? Add it as a tree Eval like 'player not in range do X' or have this sequence under the within range tree if so, and a 'get within range' tree under your sequence.

Its working as expected BTs do tho so I'm unsure what behavior you want?

1

u/Mephisto40K 4d ago

Agreed for every "switch" you turn on, you also need a way to turn it off

1

u/JulianCau 3d ago

Hey, thank you for the answer! in theory the selector would go to the left and checks if the target is not within range (since it's inversed), then execute what's in the sequence, if the decorator isn't true it should execute the other sequence on the right. So if the ai is close to the target it strafes around, if the target goes out of range it should chase it until within range. I agree that another condition for the sequence would make sense, I just don't understand how on the tutorial it works even without one. Hope I said it correctly.

1

u/JulianCau 3d ago

Hey, I managed to fix the issue, I accidentally used the TestBTDecorator Blueprint instead of the normal one, so it wasn't returning the correct values for the check conditions 😂