- Home /
Destroying a component over network?
Hello there!
I'm looking at the overloads for Network.Destroy, and it would seem that although there is an overload for destroying a particular GameObject, there isn't one for destroying a single component on a GameObject -- for example, removing a collider from a networked cube.
Admittedly, I haven't played around with this much. Would passing a component to Object.Destroy destroy the component for everyone on the network, or should I play around with RPC calls?
Thanks!
Answer by Pindwin · Jun 23, 2014 at 08:01 PM
In few words - yes, you should play around with RPC calls; assuming your server wants to inform all clients that they should destroy component, on your client you need sth like:
[RPC]
public void DestroyCollider(){
//logic of destroying collider locally or whatever
}
and then on server:
networkView.RPC("DestroyCollider", RPCMode.Others);
This is the most straightforward answer possible, but I hope it helps.