How do I change between AI Controller and Player Controller on Character Spawn?

This is complicated to explain, so please bear with me.

I have a spawning system that spawns a random (will be pre-selected later in development) AI team and Player team that the Player selects from a list of Characters.

Its based on Character Data Table in which the Character Class is selected for each Character.

The problem Im having is that the Character Parent that each character is based on can only be set to use Player controller or AI Controller. For now I have it set to AI Controller on Spawn, and since both teams are spawned this creates a problem.

I have fiddled around with the Possess node, but it always puts me in first person INSIDE the character body which is awesome.

The attack sequence for the AI is pretty straight forward (currently) and the Player attack sequence would include the press of 1/2/3/4 which goes to a skill. So, I need the Player team to be Player controlled so I can press those buttons and have them do something.

I know this is super confusing. If you have any questions please let me know.

EDIT: I should add that I use a spectator pawn during combat while the two teams fight. I dont actually want to … be the character, just choose what ability it uses.

For some reason this was changed to AI category though it has nothing to do with AI, but camera and player control

First off, in your begin play have a boolean branch that chooses player or AI controller.

Then, you need a game manager class, I usually use Game Mode, since it’s presistant in all levels.

Have a function in the game mode that gets all spawners and tell them to spawn on game start or whenever you want.

The Spawn should spawn via a foreach loop and for every character it creates, cast to it, and use random bool to pick the either player or AI.

Let me know if this answers the question

1 Like