示例#1
0
    public override void Pause()
    {
        base.Pause();

        // Freeze the movement, pause any animations.
        rbState            = Rigidbody2DSaveState.CreateFrom(rigidbody);
        rigidbody.velocity = Vector2.zero;

        animator.enabled = false;
    }
示例#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.
    }