Exemplo n.º 1
0
    private void FixedUpdate()
    {
        var prevAnimDir = animationDirection;
        var changed     = CheckDirection();

        if (changed)
        {
            var prevAnim = GetAnim(prevAnimDir);
            if (prevAnim)
            {
                prevAnim.Disable();
            }
            switch (animationDirection)
            {
            case AnimationDirection.Up:
                animUp.Enable();
                break;

            case AnimationDirection.Right:
                animRight.Enable();
                break;

            case AnimationDirection.Down:
                animDown.Enable();
                break;

            case AnimationDirection.Left:
                animLeft.Enable();
                break;

            case AnimationDirection.Idle:
                prevAnim.SetDefault();
                break;
            }
        }
    }