OnCOllisionEnter

Options
kurtdesi
edited April 2014 in DotNet
guys first of all i want to say that this networking library is awesome. However i got stuck on how to pass collisions. I am trying to check if the clients player has collided to the servers player but i cant figure it out. PLEASE help iv been stuck for so long on this one.

Comments

  • this is a sample of my code



    // if this object has collided to the clients player (i.e clients player name is rocko(clone))

    if (collision.gameObject.name == "Rocko(Clone)" && sprint == true)) { <---- THIS IS WORKING
    }

    // if this object has collided to the servers player (i.e clients player name is rocko1)

    if (collision.gameObject.name == "Rocko1" && sprint == true)) { <---- THIS IS NOT WORKING
    }
  • Tobias
    Options
    Huh, that's hard to debug from here. It simply depends on the name you give your game objects. Let's say you change the name after calling Instantiate, then that GO's name change is not synced.
    Pseudocode:
    [code2=csharp]go = PhotonNetwork.Instantiate("char",...)
    go.name = "Rocko"[/code2]
    It's only local.

    In network games, GameObjects are not identified by name but by ViewId and maybe by owner. The PhotonView component makes this possible and synced across all clients.

    You should get a reference to a gameobject's PhotonView and compare the owner (or ownerID).