Basic AI stops working after possess / unpossess

I tried searching for other Answers but they seem to be more complicated than what I need.

I have several playable ThirdPerson characters. My aim is to be able to toggle among them and the ones not currently possessed by player controller become AIs that follow the current player character around.

So upon Begin Play it works just fine, I have a lead character and following AIs. But when I switch to possess another character, they the original character and the rest – well, they don’t follow anymore. I try to switch back to no avail – they do rotate to face the player character though.

I tried diagnosing with print strings… in the beginning I have “Go” “Followed” “Failed” as expected. But after switching possessed characters I only have “Go” – it seems the AI Move To has stopped doing anything.

Note my AI are pretty simple – I don’t use behavior trees or blackboards, instead the behavior is hardcoded into the animation blueprints. Any leads might help, thanks.

Well, I’d suggest you started using BTs, it going to be a lot easier to address issues like that. To be honest I’m actually surprised that AI MoveTo works when places in an animation BP - it certainly is not expected/required to.

Cheers,

–mieszko

Hmmm it’s actually in the Third Person BP, which aside from the player inputted actions just contains an event tick to measure distance to player and other variables. The variables then gets passed to the animation BP which uses its own logic to determine animation states. I have trash mob enemies whose “AI” basically amounts to just this. I’ll probably have to implement Behavior Trees eventually with “smarter” boss AIs, by then I can probably back-implement it to the controllable characters, though I’m not too keen if it means redoing all the animation logic.

My guess is when you are possessing the AI you become it’s controller, and hen you leave, you leave it with out a controller. Maybe before possessing get the AI controller, then when unpossessing set back the AI controller from the saved value.

1 Like

i had the exact same issue and i think it’s what Night Watcher was saying, but i can’t figure out how to switch the player controller for the possessed pawn back to what it was before

Hey, try to create a variable for the player controller you want to posses in the main character that is possessing the AIs. Save the current AI controller in that variable, then take control of the AI. Now that you have done that and you want to go back to your character, just possess the main character, take the controller value you saved in the variable and assign it back to the AI.
You can also create this variable in the AI itself instead.