sunarit’s blog

Unity開発の備忘録

敵のヒットバックとNavMesh停止

敵に弾がヒットした際、ヒットバックアニメーションを再生し、NavMeshを一時停止。
StartCoroutineでコール。

public IEnumerator getHit () {
	this.GetComponent<Animator>().SetTrigger("GetHit1");
	NavMeshPath path = new NavMeshPath();
	if (agent.hasPath && currentHealth > 0) {
	agent.Stop (true);
	yield return new WaitForSeconds(myGetHitWait);
	agent.Resume();
	this.GetComponent<Animator>().ResetTrigger("GetHit1");
	}
}