RPC creates object that seemingly needs one layer for each player in the room.

I am working on a top-down, multiplayer game (~15 players per match) that uses ray casting for shooting. I am working on an ability where a player can deploy a portable shield that will appear for a few seconds and then disappear. The player who deployed the shield is able to shoot through it, but enemies cannot (think Overwatch style shields). When a player deploys the shield, an RPC is sent out to all clients saying to deploy a shield at position P and rotation R. The shield itself is not using a photonView, each client is responsible for deploying/destroying the shield.

Right now I am putting the shield on an "IgnoreRaycast" layer for the player who deployed the shield, and a "Shield" layer for all others. The problem I am running in to is that on enemy players devices, the shield that I deployed is put on the "Shield" layer, so my photonView player object on their device is visually hitting the shield when it shouldn't be.

A possible solution that I have thought of is to create a separate layer for every player/team that is in each match. Given that Unity only allows us to create 24 layers for our games, and that there will be ~15 players/teams per match in my game, this doesn't seem like the correct solution.

If anyone has solved this in their games I would love to hear how! Thanks!

Comments

  • Hi @alexturner,

    The problem I am running in to is that on enemy players devices, the shield that I deployed is put on the "Shield" layer, so my photonView player object on their device is visually hitting the shield when it shouldn't be.


    Just to be sure that I understood the problem correct: the local player can already shoot through the shield but on the remote clients' view the same shooting is blocked by the shield because of the used layers, am I right? If so, whenever a player shoots his weapon, do you use a RPC as well which is fired on the remote clients who then do the Raycasting on their machines?
  • Hi @Christian_Simon,

    You are correct. The remote clients player object cannot shoot through the shield because of the layer it is on (which is correct), but my player object on an enemy players device doesn't visually represent that I am able to shoot through the shield on my own device.

    I am using Raycasting every time a player shoots, but not via RPCs. I created an input state syncing class that uses OnPhotonSerializeView. This results in every player object calling the same Raycasting code to display the visuals, but only the player who is actually shooting will deal any damage if they hit anything.
Sign In or Register to comment.