How to add components and being registered for other players?
Options
Hi,
First of all, sorry if this topic was already posted I couldn't manage to find it sorry.
I am making a RPG where I can apply status on enemies (like vulnerability bleed etc...) but all of those are components that I add on the GameObject of the enemy.
(for example I have a class bleed that I add on the GameObject of the player or the entity that is bleeding)
I am adding the created status to the list of the observed components but the only client that sees the photonview being actualize is the one that created the script.
Is there a way to bypass this? Am I doing something wrong?
First of all, sorry if this topic was already posted I couldn't manage to find it sorry.
I am making a RPG where I can apply status on enemies (like vulnerability bleed etc...) but all of those are components that I add on the GameObject of the enemy.
(for example I have a class bleed that I add on the GameObject of the player or the entity that is bleeding)
I am adding the created status to the list of the observed components but the only client that sees the photonview being actualize is the one that created the script.
Is there a way to bypass this? Am I doing something wrong?
0
Comments
-
Hi @DrCrab,
Thank you for choosing Photon!
You have two options, choose one or the other or combine:
- use PhotonNetwork.Instantiate instead of normal Instantiate. prefabs must have PhotonView component. too many PhotonView per player is not recommended although the default limit is already too high: 1000.
- use RPC or RaiseEvent to tell everyone else to also instantiate same GameObject and the info necessary for that.1 -
I sadly can't use PhotonNetwork.Instantiate because what I need is just to add a component (I am litterally using the function in unity "gameObject.AddComponent()"). I don't need to upload the existence of a GameObject but of a Component(bleed) attached to a GameObject.
Is there a way to do it?0 -
Use the second approach via RPC or RaiseEvent then.
The client adding a component should tell the others via RPC or RaiseEvent to also add a component to the same GameObject.1 -
Sorry I didn't understand I'll test this! thanks you for your answer.0
-
It worked thanks a lot!JohnTube said:Use the second approach via RPC or RaiseEvent then.
The client adding a component should tell the others via RPC or RaiseEvent to also add a component to the same GameObject.1