public void TeleportTo(Vector3 position) { if (playerHead) { // Move using the offset of the player inside the rig. Vector3 playerOffsetInRig = playerRig.position.SetY(0) - playerHead.position.SetY(0); playerRig.position = position + playerOffsetInRig; } else { playerRig.transform.position = position; } Teleported?.Invoke(position); }
protected void EmitTeleported(LocomotionSystem locomotionSystem) { if (wasUsedToTeleport == false) { Vector3 rigPosition = locomotionSystem.xrRig.rig.transform.position; Vector3 anchorPosition = teleportationInteractable.teleportAnchorTransform.position; Vector2 flatRigPosition = new Vector2(rigPosition.x, rigPosition.z); Vector2 flatAnchorPosition = new Vector2(anchorPosition.x, anchorPosition.z); if (Vector3.Distance(flatRigPosition, flatAnchorPosition) < 0.1) { wasUsedToTeleport = true; Teleported?.Invoke(this, EventArgs.Empty); } } }
void TeleportPlayerToCounterpart(PlayerInteraction playerInteraction) { Vector3 relativePositionToThis = transform.InverseTransformPoint(playerInteraction.transform.position); Vector3 newPosition = counterpart.transform.TransformPoint(relativePositionToThis); playerInteraction.transform.position = newPosition; //playerInteraction.GetComponent<UnityStandardAssets.Characters.FirstPerson.RigidbodyFirstPersonController>().mouseLook.TurnAround(); if (playerInteraction.carryingObject != null) { relativePositionToThis = transform.InverseTransformPoint(playerInteraction.carryingObject.transform.position); newPosition = counterpart.transform.TransformPoint(relativePositionToThis); playerInteraction.carryingObject.transform.position = newPosition; } playerInteraction.TransitionWorlds(); Teleported?.Invoke(); }
internal void OnTeleported() { Teleported?.Invoke(_thisEntity); }
protected void EmitTeleported() { wasUsedToTeleport = true; Teleported?.Invoke(this, EventArgs.Empty); }