이 전에 만들었던 플레이어 이동 애니메이션은 각 방향 Idle 상태가 없었다. 그래서 아래 방향 Idle 상태로 모두 돌아와서 어색한 면이 있었다. 기획자님이 각 방향 Idle 상태를 주셔서 추가하였다.

덕분에 아주 괴랄한… 어휴.. 토나온다.
8방향 이동 애니메이션은 각 방향마다 다른 방향으로 이동할 수 있어야 애니메이션이 자연스럽다. 그래서 모든 경우의 수를 다 연결해 주어야 한다.
Idle 상태에서 모든 준비 동작으로 갈 수 있어야한다.
준비 동작에서 해당 방향 이동 애니메이션으로 갈 수 있다. 준비 동작 끼리는 모두 엮여있고 준비 동작에서 모든 Idle 상태로 갈 수 있어야 한다.
움직이는 상태에서 모든 준비 동작과 Idle 상태로 갈 수 있어야 한다.
public void Anime()
{
if(GameManager.GetInstance().playerDirection == new Vector3(-1.14f, 0, 1.14f))//UpLeft
{
animator.SetBool("inputX", true);
animator.SetBool("inputZ", true);
animator.SetBool("upLeft", true);
animator.SetBool("up", false);
animator.SetBool("upRight", false);
animator.SetBool("left", false);
animator.SetBool("right", false);
animator.SetBool("downLeft", false);
animator.SetBool("down", false);
animator.SetBool("downRight", false);
}
if(GameManager.GetInstance().playerDirection == new Vector3(0, 0, 2.0f))//Up
{
animator.SetBool("inputX", false);
animator.SetBool("inputZ", true);
animator.SetBool("up", true);
animator.SetBool("upLeft", false);
animator.SetBool("upRight", false);
animator.SetBool("left", false);
animator.SetBool("right", false);
animator.SetBool("downLeft", false);
animator.SetBool("down", false);
animator.SetBool("downRight", false);
}
if(GameManager.GetInstance().playerDirection == new Vector3(1.14f, 0, 1.14f))//UpRight
{
animator.SetBool("inputX", true);
animator.SetBool("inputZ", true);
animator.SetBool("upRight", true);
animator.SetBool("upLeft", false);
animator.SetBool("up", false);
animator.SetBool("left", false);
animator.SetBool("right", false);
animator.SetBool("downLeft", false);
animator.SetBool("down", false);
animator.SetBool("downRight", false);
}
if(GameManager.GetInstance().playerDirection == new Vector3(-2.0f, 0, 0))//Left
{
animator.SetBool("inputX", true);
animator.SetBool("inputZ", false);
animator.SetBool("left", true);
animator.SetBool("upLeft", false);
animator.SetBool("up", false);
animator.SetBool("upRight", false);
animator.SetBool("right", false);
animator.SetBool("downLeft", false);
animator.SetBool("down", false);
animator.SetBool("downRight", false);
}
if(GameManager.GetInstance().playerDirection == new Vector3(2.0f, 0, 0))//Right
{
animator.SetBool("inputX", true);
animator.SetBool("inputZ", false);
animator.SetBool("right", true);
animator.SetBool("upLeft", false);
animator.SetBool("up", false);
animator.SetBool("upRight", false);
animator.SetBool("left", false);
animator.SetBool("downLeft", false);
animator.SetBool("down", false);
animator.SetBool("downRight", false);
}
if(GameManager.GetInstance().playerDirection == new Vector3(-1.14f, 0, -1.14f))//DownLeft
{
animator.SetBool("inputX", true);
animator.SetBool("inputZ", true);
animator.SetBool("downLeft", true);
animator.SetBool("upLeft", false);
animator.SetBool("up", false);
animator.SetBool("upRight", false);
animator.SetBool("left", false);
animator.SetBool("right", false);
animator.SetBool("down", false);
animator.SetBool("downRight", false);
}
if(GameManager.GetInstance().playerDirection == new Vector3(0, 0, -2.0f))//Down
{
animator.SetBool("inputX", false);
animator.SetBool("inputZ", true);
animator.SetBool("down", true);
animator.SetBool("upLeft", false);
animator.SetBool("up", false);
animator.SetBool("upRight", false);
animator.SetBool("left", false);
animator.SetBool("right", false);
animator.SetBool("downLeft", false);
animator.SetBool("downRight", false);
}
if(GameManager.GetInstance().playerDirection == new Vector3(1.14f, 0, -1.14f))//DownRight
{
animator.SetBool("inputX", true);
animator.SetBool("inputZ", true);
animator.SetBool("downRight", true);
animator.SetBool("upLeft", false);
animator.SetBool("up", false);
animator.SetBool("upRight", false);
animator.SetBool("left", false);
animator.SetBool("right", false);
animator.SetBool("downLeft", false);
animator.SetBool("down", false);
}
// animator.loop 값 대입
if(playerMove.isMove == true)
animator.SetFloat("loop", animator.GetCurrentAnimatorStateInfo(0).normalizedTime);
if(playerMove.isMove == false)//안움직일 때 X Z 끄기
{
animator.SetFloat("loop", 0);
animator.SetBool("inputX", false);
animator.SetBool("inputZ", false);
}
}
게임매니저로 플레이어 이동 방향을 받아와서 동작하게 하였는데.. 이 방법은 안좋은 것 같다. 너무 노가다.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAnime : MonoBehaviour
{
public PlayerMove playerMove;
public Animator animator;
public Animation animation;
public int aniDir;
public int dir;
void Awake()
{
animator = GetComponent<Animator>();
}
void Start()
{
playerMove = GetComponent<PlayerMove>();
}
private void Update()
{
Anime();
}
public void Anime()
{
if(GameManager.GetInstance().playerDirection == new Vector3(-1.14f, 0, 1.14f))//UpLeft
{
animator.SetBool("inputX", true);
animator.SetBool("inputZ", true);
animator.SetBool("upLeft", true);
animator.SetBool("up", false);
animator.SetBool("upRight", false);
animator.SetBool("left", false);
animator.SetBool("right", false);
animator.SetBool("downLeft", false);
animator.SetBool("down", false);
animator.SetBool("downRight", false);
}
if(GameManager.GetInstance().playerDirection == new Vector3(0, 0, 2.0f))//Up
{
animator.SetBool("inputX", false);
animator.SetBool("inputZ", true);
animator.SetBool("up", true);
animator.SetBool("upLeft", false);
animator.SetBool("upRight", false);
animator.SetBool("left", false);
animator.SetBool("right", false);
animator.SetBool("downLeft", false);
animator.SetBool("down", false);
animator.SetBool("downRight", false);
}
if(GameManager.GetInstance().playerDirection == new Vector3(1.14f, 0, 1.14f))//UpRight
{
animator.SetBool("inputX", true);
animator.SetBool("inputZ", true);
animator.SetBool("upRight", true);
animator.SetBool("upLeft", false);
animator.SetBool("up", false);
animator.SetBool("left", false);
animator.SetBool("right", false);
animator.SetBool("downLeft", false);
animator.SetBool("down", false);
animator.SetBool("downRight", false);
}
if(GameManager.GetInstance().playerDirection == new Vector3(-2.0f, 0, 0))//Left
{
animator.SetBool("inputX", true);
animator.SetBool("inputZ", false);
animator.SetBool("left", true);
animator.SetBool("upLeft", false);
animator.SetBool("up", false);
animator.SetBool("upRight", false);
animator.SetBool("right", false);
animator.SetBool("downLeft", false);
animator.SetBool("down", false);
animator.SetBool("downRight", false);
}
if(GameManager.GetInstance().playerDirection == new Vector3(2.0f, 0, 0))//Right
{
animator.SetBool("inputX", true);
animator.SetBool("inputZ", false);
animator.SetBool("right", true);
animator.SetBool("upLeft", false);
animator.SetBool("up", false);
animator.SetBool("upRight", false);
animator.SetBool("left", false);
animator.SetBool("downLeft", false);
animator.SetBool("down", false);
animator.SetBool("downRight", false);
}
if(GameManager.GetInstance().playerDirection == new Vector3(-1.14f, 0, -1.14f))//DownLeft
{
animator.SetBool("inputX", true);
animator.SetBool("inputZ", true);
animator.SetBool("downLeft", true);
animator.SetBool("upLeft", false);
animator.SetBool("up", false);
animator.SetBool("upRight", false);
animator.SetBool("left", false);
animator.SetBool("right", false);
animator.SetBool("down", false);
animator.SetBool("downRight", false);
}
if(GameManager.GetInstance().playerDirection == new Vector3(0, 0, -2.0f))//Down
{
animator.SetBool("inputX", false);
animator.SetBool("inputZ", true);
animator.SetBool("down", true);
animator.SetBool("upLeft", false);
animator.SetBool("up", false);
animator.SetBool("upRight", false);
animator.SetBool("left", false);
animator.SetBool("right", false);
animator.SetBool("downLeft", false);
animator.SetBool("downRight", false);
}
if(GameManager.GetInstance().playerDirection == new Vector3(1.14f, 0, -1.14f))//DownRight
{
animator.SetBool("inputX", true);
animator.SetBool("inputZ", true);
animator.SetBool("downRight", true);
animator.SetBool("upLeft", false);
animator.SetBool("up", false);
animator.SetBool("upRight", false);
animator.SetBool("left", false);
animator.SetBool("right", false);
animator.SetBool("downLeft", false);
animator.SetBool("down", false);
}
// animator.loop 값 대입
if(playerMove.isMove == true)
animator.SetFloat("loop", animator.GetCurrentAnimatorStateInfo(0).normalizedTime);
if(playerMove.isMove == false)//안움직일 때 X Z 끄기
{
animator.SetFloat("loop", 0);
animator.SetBool("inputX", false);
animator.SetBool("inputZ", false);
}
}
}