Exemplo n.º 1
0
    public override void Unpause()
    {
        base.Unpause();

        // Unfreeze the movement, unpause animations.
        rbState.position = rigidbody.position;
        rbState.ApplyTo(rigidbody);

        animator.enabled = true;
    }
Exemplo n.º 2
0
    IEnumerator Teleport(Player toTeleport)
    {
        // Let anything that cares (certainly the destination) know this is teleporting something.
        teleporting.Add(toTeleport.gameObject);
        TeleportingObject.Invoke(toTeleport.gameObject);

        // Keep the player from moving.
        Rigidbody2DSaveState rbSaveState = new Rigidbody2DSaveState(toTeleport.rigidbody);

        rbSaveState.velocity.x = 0;
        toTeleport.Pause();
        toTeleport.animator.enabled = false;
        rbSaveState.ApplyTo(toTeleport.rigidbody);

        // Play the animation, and let the destination receive the player.
        yield return(PlayAnimation());

        destination.ReceiveObject(toTeleport);
        canTeleport = false;                                                   // Without this, we get an infinite teleportation loop.
    }