Can PunRpc be passed from parent gameobject to child
Hello,
I have a gameObject that has PhotonView attached, then I have other child objects connected to that parent.
Those child objects need to communicate over the network using RPC. But it seems with photon, only the parent object that has the PhotonView attached can communicate, and not any of the children.
Is there a way I can forward the RPC from the parent to the child objects, without writing individual functions in the parent to call the child functions manually?
I know in uLink networking I can specify that RPC can be called to/from any child object, but seems that cant work in photon.
Thanks
I have a gameObject that has PhotonView attached, then I have other child objects connected to that parent.
Those child objects need to communicate over the network using RPC. But it seems with photon, only the parent object that has the PhotonView attached can communicate, and not any of the children.
Is there a way I can forward the RPC from the parent to the child objects, without writing individual functions in the parent to call the child functions manually?
I know in uLink networking I can specify that RPC can be called to/from any child object, but seems that cant work in photon.
Thanks
0
Best Answer
-
if your gameobject parent A-child B structure,
add Script A class to A, B class To B, and make B inherit A.
Now Class B is child of class A
class A : monobehavior {
PhotonView photonViewA;
}
class B : class A {
PhotonView photonViewB;
void Awake()
{
photonViewB=GetComponent().photonViewA;
}
}
You can use photonView of parent GameObject now.5
Answers
-
if your gameobject parent A-child B structure,
add Script A class to A, B class To B, and make B inherit A.
Now Class B is child of class A
class A : monobehavior {
PhotonView photonViewA;
}
class B : class A {
PhotonView photonViewB;
void Awake()
{
photonViewB=GetComponent().photonViewA;
}
}
You can use photonView of parent GameObject now.5