コード例 #1
0
 //If we should chase the player, go to chase state, if not and we don't have a path, go back to idle
 public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (ChaseState.ShouldChasePlayer(animator.transform.position))
     {
         animator.SetInteger(IdleState.transitionParameter, (int)Transition.CHASE);
     }
     else if (!navAgent.hasPath)
     {
         animator.SetInteger(IdleState.transitionParameter, (int)Transition.IDLE);
     }
 }
コード例 #2
0
ファイル: IdleState.cs プロジェクト: roman10x/gamingscripts
 //Check if we should chase the player, if not - Set a random destination if we don't already have one
 public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (ChaseState.ShouldChasePlayer(animator.transform.position))
     {
         animator.SetInteger(transitionParameter, (int)Transition.CHASE);
     }
     else
     {
         if (navAgent.hasPath)
         {
             animator.SetInteger(transitionParameter, (int)Transition.WANDER);
         }
         else
         {
             SetRandomDestination(navAgent);
         }
     }
 }