๐Ÿ™‡โ€โ™€๏ธPlayer Animation

๐ŸชPlayer Animation

ํ”Œ๋ ˆ์ด์–ด์—๊ฒŒ Animator ์ปดํฌ๋„ŒํŠธ ๋„ฃ์–ด์ฃผ๊ณ , AnimatorController์ƒ์„ฑ

์ด๋™์— ๋งž๊ฒŒ ํ”Œ๋ ˆ์ด์–ด์—๊ฒŒ ์Šคํ”„๋ผ์ดํŠธ๋ฅผ ๋„ฃ์–ด์ฃผ๊ธฐ

์ƒ์„ฑ์ž๋กœ ์• ๋‹ˆ๋ฉ”์ดํ„ฐ ํšจ๊ณผ ๋„ฃ์–ด์ฃผ๊ธฐ

MoveDir _dir = MoveDir.None;
public MoveDir Dir
{
    get { return _dir; }
    set
    {
        if (_dir == value)
            return;

        switch (value)
        {
            case MoveDir.Up:
                _animator.Play("WALK_BACK");
                transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
                break;
            case MoveDir.Down:
                _animator.Play("WALK_FRONT");
                transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
                break;
            case MoveDir.Left:
                _animator.Play("WALK_RIGHT");
                transform.localScale = new Vector3(-1.0f, 1.0f, 1.0f);
                break;
            case MoveDir.Right:
                _animator.Play("WALK_RIGHT");
                transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
                break;
            case MoveDir.None:
                if (_dir == MoveDir.Up)
                {
                    _animator.Play("IDLE_BACK");
                    transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
                }
                else if (_dir == MoveDir.Down)
                {
                    _animator.Play("IDLE_FRONT");
                    transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
                }
                else if (_dir == MoveDir.Left)
                {
                    _animator.Play("IDLE_RIGHT");
                    transform.localScale = new Vector3(-1.0f, 1.0f, 1.0f);
                }
                else
                {
                    _animator.Play("IDLE_RIGHT");
                    transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
                }
                break;
        }

        _dir = value;
    }
}

์—ฌ๊ธฐ์„œ _dir = value;์ด ๋ถ€๋ถ„ ๋บด์ง€๋ง์ž;;

๊ทธ๋ฆฌ๊ณ  ์ƒ์„ฑ์ž๋ฅผ ๋งŒ๋“ค์–ด ์คฌ์œผ๋‹ˆ๊นŒ _dir์€ Dir๋กœ ์ „๋ถ€ ๋ฐ”๊พธ๊ธฐ

ํƒœ๊ทธ:

์นดํ…Œ๊ณ ๋ฆฌ:

์—…๋ฐ์ดํŠธ: