// 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) { _player = GameObject.FindGameObjectWithTag("Player").transform; _cruiserEnemy = animator.gameObject.GetComponent <CruiserEnemy>(); _transform = animator.gameObject.transform; _cruiserEnemy._currentMinTurn = _cruiserEnemy._initialMinTurn; }
// 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) { _transform = animator.gameObject.transform; _player = GameObject.FindGameObjectWithTag("Player").transform; _cruiserEnemy = _transform.GetComponent <CruiserEnemy>(); _waypoints = _cruiserEnemy.Waypoints; _cruiserEnemy.TargetPos = _waypoints[_targetPointIndex]; _cruiserEnemy._currentMinTurn = _cruiserEnemy._initialMinTurn; _timeSinceLastPlayerSighting = 0.0f; _targetPointIndex = 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) { _player = GameObject.FindGameObjectWithTag("Player").transform; _cruiserEnemy = animator.gameObject.GetComponent <CruiserEnemy>(); _transform = animator.gameObject.transform; _cruiserEnemy._currentMinTurn = _cruiserEnemy._initialMinTurn; _waypoints = _cruiserEnemy.Waypoints; _targetPos = _transform.position; foreach (Vector3 pos in _waypoints) { if (Vector3.Distance(_transform.position, pos) > Vector3.Distance(_transform.position, _targetPos)) { _targetPos = pos; } } _cruiserEnemy._currentMinTurn += Time.deltaTime * 0.01f; _cruiserEnemy.TargetPos = _targetPos; }