When a character starts chasing me, he can turn around and go the other way at any moment
Hey there @Skyper4342! Welcome to the community! So this is looking like it probably stems from the delay node. What’s likely happening is that the character seems to be momentarily losing sight, which triggers the delay node to start counting down. Then when the AI makes it to the destination, it’s able to see the player again, starts to chase, but fails because the delay that was set a couple seconds back now fires.
One tip I always give is that you should never use delays on anything that isn’t guaranteed to be contiguous. You should also never introduce a delay inside of a tick based function since every tick a new delay is spun up, not waiting on the old one to finish, it will just keep making new ones.
So in this case, how do you fix it? Replacing the delay with a retriggerable delay could go a long way, but you may also need to check for line of sight at the end of it as well so it does not try and trigger if by the end of the delay they can then see the player. Alternatively you can look into learning behavior trees for AI, which can handle the state logic a little easier than managing it by hand once you get more used to it.