private void OnTriggerEnter(Collider other) { string name = other.gameObject.name; print(name); if (name != "OVRPlayerController") { if (name != "Terrain") { NetworkedRootController otherNRC = other.transform.root.GetComponent <NetworkedRootController>(); if (otherNRC != null) { int otherID = otherNRC.conn_id; if (otherID != pid) { otherNRC.player.TakeDamage(dmg); if (hasAuthority) { thwack_high.Play(); } else { thwack.Play(); } this.GetComponent <Collider>().enabled = false; } } } } }
void CmdSpawnPlayer() { // id == 1 for host, id == 2 for p2 conn_id = NetworkServer.connections.Count; Vector3 init_pos = new Vector3((conn_id == 1 ? p1_x : p2_x), 0, 0); myPlayerObject = Instantiate(KnightPrefab, init_pos, Quaternion.identity); NetworkedRootController nrc = myPlayerObject.GetComponent <NetworkedRootController>(); nrc.conn_id = conn_id; NetworkServer.SpawnWithClientAuthority(myPlayerObject, connectionToClient); }