Hello.
I have two players. A FPS character and a UAV.
If i want to switch between, how can i do it? I also want to disable the other when switched so no cross controlling happens. Does anyone know how to do this? Like I press (u) it will disable the FPS character, and switch to the UAV, but when I press U again, it will switch back, disabling the UAV.
Thanks
What you’d probably want to do is when one activates, the other deactivates. I use this with my FirstPerson camera and ThirdPerson camera. Here is the script:
var Player1 : GameObject;
var Player2 : GameObject;
function Update ()
{
if(Input.GetKeyDown(KeyCode.P))
{
Player1.SetActive(true);
Player2.SetActive(false);
}
if(Input.GetKeyDown(KeyCode.O))
{
Player2.SetActive(true);
Player1.SetActive(false);
}
}
This has been tested and works properly. Attach this code to both of the Players in the Update function. Hope this solves your problem 