How to create AI follow - attack - follow behavior?

I’m trying to get the player to summon a creature, have that creature follow the player until an enemy walks within the sight range and then attack it, after the enemy dies and is destroyed, returning to the player. I can either get the AI to always attack or always follow, but can’t seem to get the correct setup. I’ve spent over 4 consecutive hours on this to no avail… Any help would be appreciated.

are you trying to do this in blueprint or in a behavior tree?

in either case its pretty simple, just have a variable that represents the target to attack. if the value is valid then you will use the attack action, if the variables value isnt valid or isnt set then you use the movement.

of course you could combine that with ai perception to automate things.

heres a very basic example in blueprint.