Rendering players per camera

Hey guys, I’m hoping you can solve this one for me, as It’s giving me quite a headache!

I’m working on a multiplayer game, but it also has splitscreen. Rendering the players for the network players is fine, as you don’t have to draw the first person weapon, legs, etc.

Here’s where the problem is. For the split screen players, you not only have the player model, but the weapon too. What I’ve tried doing already is getting the separate list of renderers of the first person weapon, and the first person camera, and tried to force the camera to not render it, but that doesn’t seem to work.

Here’s the issue I have in more of a visual form:
alt text

The green is what I want the other splitscreen players to see in their camera (so basically, just the other split screen players body, not their weapon). The red is what I want the splitscreen players to see only in their camera (their own fps weapon).

I tried using 1 layer called invisible which I add the renderers to a list where the layer is changed OnPreCull(), but to no avail.

I hope you guys can solve my issue here!

1 Answer

1

I would use 2 different cameras, placed two different places and then let the camera output cover half of the screen.

I have used multiple cameras before as HUD effects, rendering some different part of the stage/scene where I had the scores, pickup objects etc. Worked fine. You can render without background too, if you need the dashboard to be transparent. But in your case I would setup two different cameras, vertical or horisontal beside each other.

Once you have two cameras, its even more simple to draw the contents, isnt it?

For each camera, you can also specify a culling mask. If you place the “dont show this in camera 1” objects in a seperate mask and the “dont show this in camera 2” objects in another. It seems quite easy to me.

let me know if this works for you.

If I use more than one camera, then I won't be able to preserve the shadowing on the weapons. I'd also like to keep the game as tuned for performance as possible. Having 2 cameras per player, with the ability to have 4 players at once = 8 cameras potentially. Ouch. I'm sure there's a way you can do it using Unity's culling system, I just think I'm going about it the wrong way. I'd definitely like to not go the standard '2 Camera' way though, as there's loss in shadow quality and performance.