状态机是这样的
包含静止、跑、攻击、死亡四个动画
下面是核心代码(PS:代码高亮插件出问题了将就看一下吧。。)
AnimatorStateInfo stateInfo m_ani.GetCurrentAnimatorStateInfo(0);if (stateInfo.fullPathHash Animator.StringToHash("Base Layer.idle") m_timer - Time.deltaTime;if (m_timer > 0)return;if (Vector3.Distance(m_transform.position, m_player.m_transform.position) <1.5f){m_ani.SetBool("attack", true);}else{m_timer 1;m_agent.SetDestination(m_player.m_transform.position);m_ani.SetBool("run", true);}}if (stateInfo.fullPathHash Animator.StringToHash("Base Layer.run") m_timer - Time.deltaTime;if (m_timer <0){m_agent.SetDestination(m_player.m_transform.position);m_timer 1;}if (Vector3.Distance(m_transform.position, m_player.m_transform.position) 1.0f){m_ani.SetBool("idle", true);m_timer 2;}}
转:https://www.cnblogs.com/fws94/p/6591275.html
【本文来源:韩国服务器 https://www.68idc.cn欢迎留下您的宝贵建议】