Network Multiple Cameras
I am reasonably new to Unity and have been working through the Unity tutorials, specifically the Survival Shooter. I thought I may have a go at converting this tutorial game to a network multiplayer.
The camera in this tutorial follows the player from a fixed rotation. To accomplish this the tutorial uses one camera (Not a child of the player), tracks the players position and updates the camera position accordingly.
I want each player who joins the network game to have the camera to follow their character with a fixed rotation (same as the tutorial).
I first attempted this by instantiating a new camera for each player, but I found that the new camera was overriding the last. I also attempted to disable the other cameras if they were a local player but found that the other players cameras were being disabled when a new player joined.
I then scrapped the multiple camera idea and attempted to use one camera, but with a similar result where it would only track the latest player.
What is the correct solution to network multiplayer cameras that are not a child of the player?
Answer by _Spanda_ · Jul 23, 2016 at 04:43 PM
public Camera cam;
void Update () {
if(!isLocalPlayer)
{
cam.enabled = false;
return;
}
I had the exact same problem, and this solution I came up with. Have a good day!
Thanks, I was having the same problem and it fixed it. Im not entirely sure why (noob I know sorry), but this didnt work in void Update for me ins$$anonymous$$d it works in void start. Not complaining just glad it works.
Anyway thanks again. :)
Answer by rattler22snake · Aug 09, 2018 at 01:44 AM
Wow thanks dude. I just got this problem and instead of hitting my head against a wall for hours trying to figure it out on my own I looked it up. Lots of help. Much Thanks
Answer by Louisicraft · Mar 27, 2021 at 01:56 PM
when i do this it ignores all culling Masks on the connecting clients and culling Mask don't work at all on this Camera anymore! Please Help
Answer by harunakdogan · Jul 02, 2021 at 12:27 AM
Just attach a Camera to the Player preFab and add this line to the Start method of the Player script:
GetComponent<Camera>().enabled = isLocalPlayer ? true : false;
Your answer
Follow this Question
Related Questions
Photon camera problum 0 Answers
How to prevent other players from activating triggers for all players? 0 Answers
How to make multiplayer with multiple local cameras? 1 Answer
UNET (Multiplayer) calling [command] function twice 0 Answers
What is NetworkTransport.Shutdown() doing? When I must to call it? 0 Answers