Example #1
0
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     GovFSM           = animator.GetComponent <GovForceFSM>();
     astar            = animator.GetComponent <AStarNavigation>();
     astar.stopRadius = astar.initialstopRadius;//set to the original stopRadius
     visibleTarget    = GovFSM.GetFirstVisibleObject(GovFSM.EnemyAspects);
     if (visibleTarget != null)
     {
         //Transition to Chase
         animator.SetBool("EnemyLost", false);
     }
 }
Example #2
0
    // OnStateEnter is called before OnStateEnter is called on any state inside this state machine
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        animator.SetBool("EnemyLost", false);
        astar  = animator.GetComponent <AStarNavigation>();
        GovFSM = animator.GetComponent <GovForceFSM>();

        //set stopping distance to shooting stop distance
        astar.stopRadius = GovFSM.startShootingRange;
        visibleTarget    = GovFSM.GetFirstVisibleObject(GovFSM.EnemyAspects);
        //Check if there is a visible object with this aspect & proceed to chase
        if (visibleTarget != null)
        {
            astar.ChangeGoalPosition(visibleTarget.transform.position);
        }
    }
Example #3
0
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     //set enemy not lost
     animator.SetBool("EnemyLost", false);
     GovFSM          = animator.GetComponent <GovForceFSM>();
     astar           = animator.GetComponent <AStarNavigation>();
     astar.isStopped = true;//activate astar
     ResetShootTimer(GovFSM);
     visibleTarget = GovFSM.GetFirstVisibleObject(GovFSM.EnemyAspects);
     if (visibleTarget != null)
     {
         TurnToTarget(animator, visibleTarget, GovFSM);
         FireProjectile(animator);
     }
     else
     {
         //Transition to LastKnownPosition
         animator.SetBool("InShootRange", false);
         astar.isStopped = false;//deactivate astar
     }
 }
Example #4
0
 private void ResetShootTimer(GovForceFSM _govfsm)
 {
     MaxTime     = _govfsm.shootInterval;
     currentTime = 0;
 }
Example #5
0
    // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
    //override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    //{
    //
    //}

    // OnStateMove is called right after Animator.OnAnimatorMove()
    //override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    //{
    //    // Implement code that processes and affects root motion
    //}

    // OnStateIK is called right after Animator.OnAnimatorIK()
    //override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    //{
    //    // Implement code that sets up animation IK (inverse kinematics)
    //}
    private void TurnToTarget(Animator _animator, GameObject _target, GovForceFSM _govfsm)
    {
        Quaternion lookRot = Quaternion.LookRotation(_target.transform.position - _animator.transform.position);

        _animator.transform.rotation = Quaternion.Slerp(_animator.transform.rotation, lookRot, _govfsm.turnSpeed * Time.deltaTime);
    }
Example #6
0
 private void OnEnable()
 {
     GovForce = (GovForceFSM)target;
 }
Example #7
0
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     astar  = animator.GetComponent <AStarNavigation>();
     GovFSM = animator.GetComponent <GovForceFSM>();
     EnemyFoundCheck(animator);
 }