- Home /
How To Make a Character switch like in the Lego Games
Hello, I'm Trying to find out how to make the switch between characters with only using the one camera, but once the switch is complete then the original character is still there and is it's own AI until the player takes control again
Comment
Answer by Zodiarc · Oct 26, 2016 at 06:38 AM
The easiest way I could think of is, you add the AI script and the player control script to both characters. On one character the AI script is deactivated on the other the player control script. Then you define a button that when it's pressed activates the other script (AI activates player, player activates AI) and deactivates itself. Something like that:
if(Input.GetKeyDown(KeyCode.F)) {
GetComponent<AI>().enabled = true;
this.enabled = false;
}
if(Input.GetKeyDown(KeyCode.F)) {
GetComponent<Player>().enabled = true;
this.enabled = false;
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612095434im_/https://answers.unity.com/themes/thub/images/avi.jpg)