Example #1
0
        public virtual void AfterTeleport()
        {
            if (FadeScreenOnTeleport && fader)
            {
                fader.DoFadeOut();
            }

            // Call any After Teleport Events
            OnAfterTeleport?.Invoke();
        }
Example #2
0
        public virtual void AfterTeleport()
        {
            if (FadeScreenOnTeleport && fader)
            {
                fader.DoFadeOut();
            }

            // Call any After Teleport Events
            OnAfterTeleport?.Invoke();

            // Call Event on Teleport Destination if available
            if (DestinationObject)
            {
                DestinationObject.OnPlayerTeleported?.Invoke();
            }
        }
Example #3
0
        IEnumerator doTeleport(Vector3 playerDestination, Quaternion playerRotation, bool rotatePlayer)
        {
            if (!setVariables)
            {
                setupVariables();
            }

            controller.enabled = false;
            playerController.LastTeleportTime = Time.time;

            // Calculate teleport offset as character may have been resized
            float yOffset = 1 + cameraRig.localPosition.y - playerController.CharacterControllerYOffset;

            // Apply Teleport before offset is applied
            controller.transform.position = playerDestination;

            // Apply offset
            controller.transform.localPosition -= new Vector3(0, yOffset, 0);

            // Rotate player to TeleportMarker Rotation
            if (rotatePlayer)
            {
                controller.transform.rotation = playerRotation;

                // Force our character to remain upright
                controller.transform.eulerAngles = new Vector3(0, controller.transform.eulerAngles.y, 0);
            }

            // Call any After Teleport Events
            OnAfterTeleport?.Invoke();

            yield return(new WaitForEndOfFrame());

            // Re-Enable the character controller so we can move again
            controller.enabled = true;
        }