- Home /
How to set up multiple cameras for multiplayer
I have done some basic unity coding and wanted to turn a maze game i made into a multiplayer game. i followed several tutorials including the one in unity documentation and everything is working except whenever a new player joins everyone views the game from their perspective. I have a camera hooked to the player prefab which may be my problem. I have searched the forums for the answer but they all appear to use the deprecated NetworkView. If someone can tell me how to go about it id appreciate it.
Answer by JaredHD · Oct 01, 2017 at 07:23 AM
Ah I had this problem to. A simple fix is to disable the new players camera on join.
I have a script called "PlayerSetup" which loops through an array and disables components on other players on join. Here is a part of my PlayerSetup script:
//Assign this in the inspector (Things you want disabled)
[SerializeField]
GameObject[] objectsToDisable;
//Runs when the player joins. (Remember this will run on every player in the scene)
private void Start()
{
if (isLocalPlayer)
return;
DisableObjectOnClient();
}
//Loops through player objects to disable
private void DisableObjectOnClient()
{
foreach (GameObject i in objectsToDisable)
{
i.SetActive(false);
}
}
Hope that helps. If you have any questions feel free to ask
Your answer
Follow this Question
Related Questions
Spawning problems with cameras 1 Answer
Network or camera desync or something else? 0 Answers
network camera big problem 1 Answer
Unet spawn a camera? 0 Answers
How do I spawn a Client camera parented to a host Controller 0 Answers