- Home /
Want two cameras to display the scene differently
I am building a simple 2D split screen game. All of the players start at the same location, but look different. Right now, one player is in front of all of the other players.
I want the player that is in front of all of the other players to vary between cameras. I would like player 1's camera to display player 1 on top, players 2's camera to display player 2 on top, etc.
Is this possible?
I know it has been a long time since I posted on this, but I have been busy.
Neither of the links you posted address what I am trying to do. $$anonymous$$aybe I didn't not explain well enough.
Here we have Player1 ahead of the other players. There is no problem, because he is at a different location as them. Players 2, 3, and 4 are on the same location, though. This is great for player 4, because player 4 is on top of all the players, but I would like it to be that a player is on top on their own screen.
In other words, I would like DUBZZ to be on top in the top-right screen, GRANT on top in the bottom left screen, and $$anonymous$$ARAN on top in the bottom right screen.
I also want it to be the case that the other players are still displayed on every screen, just that the player whose screen it is will always be on top if there is such a collision.
Is this possible? Please help
Answer by maccabbe · Mar 13, 2015 at 09:23 PM
There are a few ways to do this.
1) Have a foreground and background player object for each player. Each pair of gameObject would both move and act the same way as a single player object. However each object has a z position so all foreground objects are on top of all background objects and all objects are on different layers (let's call them fg1, bg1, etc). Then each camera would only show 1 foreground and 3 background layers, depending on the camera. For instance player 1's camera would show fg1, bg2, bg3, and bg4 layers. Since the gameObjects in the foreground layer are in front of the gameObjects in the background layer this means player 1 would always be in front for player 1. Do the same for the other three players (except switch fg1 with bg1 and bg# with fg#).
2) Use two cameras, a foreground and background camera for each player camera. Assign the foreground camera to draw after the background camera. Then put each player on a different layer. Have player 1's background camera only draw the layers player2, player3, and player 4 and player 1's foreground camera draw the layer player1. This will create the effect that player 1 is always on top of the other 3 players. Do the same for the other 3 players.
Answer by Landern · Nov 26, 2014 at 08:49 PM
Search and you will find this is common:
http://forum.unity3d.com/threads/2-cameras-running-the-same-time.44911/
http://answers.unity3d.com/questions/10206/how-can-i-show-split-screen-or-multiple-camera-vie.html
I do not think that these answer my question. They seem to address the idea of having two cameras in different locations. I already have the cameras following the appropriate players, I just want the appropriate player to be on top of the other ones.
The first link talks about having two cameras in the same scene, but with different perspectives. I have the perspective part figured out, I need two cameras to be looking at the same players, but camera 1 displays player 1 on top of player 2 and camera 2 displays camera 2 on top of player 1.
The second link is just talking about making a split screen game with two cameras, which I have already figured out.