C# Rookiss Part7 MMORPG : Player Animation
๐โโ๏ธ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
๋ก ์ ๋ถ ๋ฐ๊พธ๊ธฐ