void OnPlayerMsg(PlayerMessage msg) { SetPosition(msg.targetConnID, msg.pos.x, msg.pos.y, msg.pos.z); if (msg.targetConnID == network.connID) // teleport back in { players[msg.targetConnID].gameObject.SetActive(true); portals.LeavingPortal(msg.portalIdx); } else { SetCameraPos(msg.targetConnID, msg.camPos.x, msg.camPos.y, msg.camPos.z); } }
void OnTriggerEnter2D(Collider2D collider) { if (!collider.GetComponent <PlayerMove>()) { return; } Tunnel t = manager.GetConnectedPortal(this); if (t == null) { return; // die } // teleport away Vector3 dir = ScreenToWorldVector(t.entryCenter - t.targetCenter, manager.player.cameras[t.targetWindow]); Vector3 pos = t.target.transform.position + dir; manager.player.SetPosition(t.targetWindow, pos.x, pos.y, pos.z); manager.player.SendPlayerMsg(t.targetWindow, t.targetPortalIdx); collider.gameObject.SetActive(false); manager.LeavingPortal(t.targetPortalIdx); }