• Home  / 
  • Unity3D
  •  /  Switching Control of a Character between Player & AI in Unity3D

Switching Control of a Character between Player & AI in Unity3D

Do you want to allow players to take control of any character in your Unity3D game? With the right architecture, it’s not too hard to make this happen. Switch between player controlled and AI control for your characters easily by splitting out the logic and swapping them when you need. A system like this can help with sports games (taking control of a single character at once) or any other situation where you may have an NPC that you want to become player controlled.. think games where your character can charm/control enemies to fight along side them. Swapping out the enemies ‘brain’ is a simple clean solution.

Video

Conclusions

While this is a basic example of the concept, you can take it a lot further in a real game. You can build up state machines, use ScriptableObjects to define your brains, and build up a strong interchangeable system character control.