Search Unity

object instance across network

Discussion in 'Multiplayer' started by meinboi, May 24, 2009.

  1. meinboi

    meinboi

    Joined:
    May 13, 2009
    Posts:
    54
    how do I find an instance of an object over the network?

    I'm trying something like this, but it causes a crash:
    networkView.RPC("setTarget", RPCMode.Others, target.networkView.viewID);
    networkView.RPC("doAttack", RPCMode.All);

    @RPC
    function setTarget(viewID : NetworkViewID) {
    var view : NetworkView = NetworkView.Find(viewID);
    if (view) target = view.gameObject;
    }
     
  2. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Assuming the object has been instantiated over the network properly..you could just call an RPC on the object. This should automatically call the right function on the same gameobject on the various other clients.