Player's visible through walls

Hi,

I’m using URP and i set up the Forward render so that Red and Blue Players are visible behind walls… But the issue is each player can see one another through the wall when it should just be themselves.

Blue players are set to Layer “BluePlayer” and Red Players are set to “RedPlayers

What’s the best way to make it so that Red player can only see Red player when behind a wall and only Blue can see Blue… i am using a custom Forward Render… i am completely stuck.

I assume you do that with render feature. You can control it from script. Set layer filter at online game startup or if you use 2 features for each team then disable one of them.

Can you explain a little more? I am new to using layers and URP.

Right now Player1 Spawns in with layer “RedPlayer” Player 2 Spawns in as “BluePlayer” I created a custom render and this is what i get.

6003521--646565--upload_2020-6-20_11-35-23.png

Player red is seen through the object… But from Player Reds perspective player Blue is seen through the building as well.

The settings of the custom render are:

6003521--646568--upload_2020-6-20_11-36-5.png

Under Layer Mask i have both Blue and Red player selected… I understand why it is happening… I just don’t no how to make it so that only the player can see themselves through the wall and not the other player…

Not sure this is the right approach… seems like it would work perfectly for a single player game. :smile:

1 Like

Most easiest way for you is to make 2 renderers. Or as to say, just copy this renderer and in one select blue and in other red layer and afterwards select right renderer for your camera.

I may have found a simple way to do this if i can figure out the shader graph. I made this shader but when i put it on the object it turns it a solid color…

6003749--646625--upload_2020-6-20_13-23-10.jpg

Before:
6003749--646628--upload_2020-6-20_13-24-6.png

After I apply the shader:

6003749--646631--upload_2020-6-20_13-25-31.png

But the object starts to fade when the camera gets to close which would work cause the camera follows the player. If i can figure out how to keep its orginal material on it this would be perfect.

Remap is wrong choise. You want lerp. It will get your distance from min to max in range of 0 to 1.

Ok, but how do i get it to keep its original material instead of being a solid color and still fade out?

  1. way. You can find shader which is used for building and then add into it current shader. That way you will merge both and will have all benefits.
  2. way. You can add stencil/mask stage before drawing building. Example in link.
    SLIDEFACTORY - See Through Objects With Stencil Buffers Using Unity URP