// 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) { ap = animator.gameObject.GetComponent <AgentPatrol> (); agent = animator.gameObject.GetComponent <PolyNavAgent> (); shoot = animator.gameObject.GetComponent <RepeatShoot> (); oldMaxSpeed = agent.maxSpeed; oldStoppingDist = agent.stoppingDistance; oldSlowingDist = agent.slowingDistance; oldAccelRate = agent.accelerationRate; oldDecelRate = agent.decelerationRate; // SetNewAgent (); agent.SetDestination(ap.playerLastPos); if (shoot) { UpdateTargetPos(); shoot.StopShoot(); } shooting = false; // if(shoot){ // shoot.StartShoot (); // shooting = true; // } }
// 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) { ap = animator.gameObject.GetComponent <AgentPatrol> (); agent = animator.gameObject.GetComponent <PolyNavAgent> (); shoot = animator.gameObject.GetComponent <RepeatShoot> (); if (agent) { agent.enabled = false; } if (shoot) { shoot.StopShoot(); } shooting = false; }