스크립트를 이용하여 Animatorcontroller의 Parameters로 설정한 파라미터로 스테이트를 전환합니다.

그럼 이제 전환하는 스크립트를 준비합니다!

using UnityEngine;

public class CharaAnimation : MonoBehaviour

{

Animator animator;

CharacterStatus status;

Vector3 prePosition;

bool isDown = false;

bool attacked = false;

public bool IsAttacked()

{

return attacked;

}

void StartAttackHit()

{

Debug.Log("StartAttackHit");

}

void EndAttackHit()

{

Debug.Log ("EndAttackHit");

}

void EndAttack()

{

attacked = true;

}

void Start ()

{

animator = GetComponent<Animator>();
status = GetComponent<CharacterStatus>();
  
prePosition = transform.position;

}

void Update ()

{

Vector3 delta_position = transform.position - prePosition;
animator.SetFloat("Speed", delta_position.magnitude / Time.deltaTime);
  
if(attacked && !status.attacking)

{

attacked = false;

}

animator.SetBool("Attacking", (!attacked && status.attacking));

if(!isDown && status.died)

{

isDown = true;
animator.SetTrigger("Down");

}

prePosition = transform.position;

}

}

이렇게 셋팅합니다.

블로그 이미지

이사가는 사람

안녕하세요 블로그를 옮기려고 생각하고 있습니다. 해당 블로그는 폐기하고 다음 다른 블로그에서 뵙도록 하겠습니다. 감사합니다!

,