photonView.isMine working wierd

Options
photonView.isMine returns true, when it is in the master.
But, it returns false, when it is in a client.
Is it normal ?

Comments

  • Hi @mhhk88,

    it depends on. The isMine condition is true, if the client is the owner of the object. Without using Ownership Transfer, the client who creates an object, is the owner of it and furthermore the isMine condition is true again.

    If the object is a scene object and the ownership haven't been transferred, the isMine condition is always true for the MasterClient.

    Hint: the isMine condition is always true for the current owner of the object and false for everyone else.
  • mhhk88
    Options
    I think my question was not clear. Sorry for that.
    In a game scene, there is a GameObject named GameManager. Actually this is an empty object that a script only. This empty object has PhotonView for calling photonView.RPC.
    I ask isMine condition and it returns true when this is a master. But, when this is a client, it returns false. That makes me confused.
    Like you said above, isMine condition is always true, if I am the owner of the object.
    I am the owner of the script which means it's running on my device.
    Is it wrong use?
  • Since this object is already placed in the Unity Editor, it is handled as a Scene Object, so this object is owned and controlled by the MasterClient by default.

    I am the owner of the script which means it's running on my device.


    The object is available on each clients' device who is connected to the room. Furthermore scripts attached to this object are processed on each client in the same room. An example: if you have two or more clients in a room and there is an object in the scene with an attached script, which has an Update function: the Update function will be called on all clients each frame. This is the reason why there is the isMine condition. Having this added to the Update function, you can prevent certain clients to process the entire or certain parts of the function. This is especially useful for handling input because you only want to apply input to an object, which belongs to a certain user - isMine.