Photon Instantiate prefab on a layer

Options
Hi,

Basically I am developing a mobile game where the touch input (destination of player) works as a raycast.
So I have placed different gameobjects on different layers depending on what they are: Friendly, Enemy, Obstacles, Walkable. If I click on a gameobject on the Friendly layer nothing happens, but if I click on a gameobject on the Enemy layer I attack it.

A prefab "Footman" can be instantiated by both players (RTS deathmatch) on the network.
The question is: How to make this prefab be on the Friendly layer to me but Enemy layer to my competitor, and vice versa?

Comments

  • Hi @rtwo2008,

    I guess the easiest solution in this case is to attach a new or use an existing and already attached script and use its Awake (or Start) function. In this function you can get a reference to the PhotonView component and check the isMine value. If this condition is true (means that the client is the owner of the object) the client can set the Layer to 'Friendly'. If the client is not the owner (the condition is false) he can set the Layer to 'Enemy'.
  • rtwo2008
    rtwo2008
    edited February 2018
    Options
    Thank you I will try it.

    Is it bad design strategy to have the same object have a certain tag (or layer) on one client, and a different tag(layer) on another client? Or is it a common networking design strategy.
  • I guess it's best, that all objects have the same options applied on all clients.
  • rtwo2008
    Options
    True. Thanks.