Hello I’m new using Cinemachine and I’m working in a local multiplayer game for class, when depending the number of players selected in a previous scene then the players prefab are instantiated and splits the camera.
For each player I create a Cinemachine Brain and a Cinemachine virtual Camera and via script and then I split the camera.
My problem is that the Live Camera of the Player 1 aims to the second player and changing the priority of the players or add each player to a different Layer and then ignore layers in the culling mask does nothing.
I tried this tutorial but it doesn’t work for me.
If a disable the GameObject then the virtual Camera switches to Player 1 but doing this ends the game.
Could you help me please?
I’m a little confused about what you’re describing. Players don’t have priority, so I don’t understand what you mean when you say “changing the priority of the players”. You shouldn’t be putting the players on different layers, just the vcams.
Conceptually, it’s like this:
- Put all your players, and things that the cameras will render, on one or more “game content” layers. These layers are visible to all the cameras with the brains.
- Then, one special layer for the Player1 vcams. All player1 vcams belong to this layer and no other. Only Player1 Camera/Brain sees this layer (in addition to the “game content” layers).
- Then, another special layer for the Player2 vcams. All player2 vcams belong to this layer and no other. Only Player2 Camera/Brain sees this layer (in addition to the “game content” layers).
Does that make sense?
Thank you for your answer.
I was meaning the priority of the virtual cameras that are child of the player Game objects.
The virtual camera of player 1 belongs to the layer P1 Cam and the player 2 virtual cam belong to P2 Cam.
Then the Camera of each player with de Cinemachine brain ignores the other player cam layers.
But only if I disable the P2 Game object then the virtual Camera of the player 1 changes it’s objective to the player 1.
Really appreciate your help.
Normally you shouldn’t make vcams children of the players. You can make them separate objects, children of a common parent in the prefab if you like.
Your camera should see only P1 layer, not P3 and P4.
Try putting all priorities to the same value. It’s not clear to me why you need them at all. Each brain will find the active vcam on the layer that it can see.
1 Like
I ignored P3 and P4 layer from the culling mask but still not working.
I put the priorities at the same value but nothing happens. I used it to try to make the P1 camera brain Live Camera get the Player 1 prefab. At this moment the Player 1 Live Camera it’s aiming to the player 2 prefab like the first image I uploaded.
I managed to fix my problem!
The solution was indeed to stop making the virtual cameras children of the players, after that it still was necessary to use the priorities but it works.
After that I modified the values of the virtual cameras via script and it looks perfect.
Thank you so much for your help.
2 Likes