public class NPC_Animation : MonoBehaviour
{
    Animator anim;

    // Start is called before the first frame update
    void Start()
    {
        anim = GetComponent<Animator>();
        anim.applyRootMotion = false;//humanoid에서 캐릭터 위치가 바뀌는것을 방지한다.
        
    }

    // Update is called once per frame
    void Update()
    {
        int pickAnumber = Random.Range(1, 6);
        anim.SetInteger("ani", pickAnumber); //ani라는 int를 animator에 추가

    }
}

캐릭터의 모션 파라미터 타입을 int로 설정한후에 랜덤으로 동작하게 만들었습니다.

'Unity > C#' 카테고리의 다른 글

유니티의 Object 이해  (0) 2020.12.06
Scene 재시작  (0) 2020.11.21
EditorWindow  (0) 2020.10.30
간단한 애니메이션 스크립트  (0) 2020.09.08
C# 기초 기억창고  (0) 2020.08.09