Example #1
0
    void UpdateTeleportPosition(ITransitionLocation transition)
    {
        Vector2 difference = playerBody.position - transition.TransitionPosition;

        if ((difference.sqrMagnitude < (SnapDistance * SnapDistance)) && (rotateEverything.IsAnimated == false))
        {
            // Snap the character to the target position
            playerBody.position = transition.TransitionPosition;

            // Make the character dynamic again
            playerBody.isKinematic = false;

            // Reset flags
            CurrentMode = Mode.Playing;

            // Run the function pointer
            if (onRespawnComplete != null)
            {
                onRespawnComplete();
                onRespawnComplete = null;
            }
        }
        else
        {
            // Animate the character movement to the target
            playerBody.position = Vector2.Lerp(playerBody.position, transition.TransitionPosition, (Time.unscaledDeltaTime * teleporterSpeed));
        }
    }
Example #2
0
 public static void RotateTo(ITransitionLocation transition)
 {
     if (transition != null)
     {
         // Determine the target angle
         TargetAngle         = transition.RotationPosition;
         instance.IsAnimated = true;
     }
 }