// 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) { _playerStateMachine = animator.GetComponent <ICharacterStateMachine>(); _mover = animator.GetComponent <IDirectionMoverComponent>(); _minDistance = _playerStateMachine.DistanceThreshold + _playerStateMachine.ArrivingDistance; }
private void Awake() { _mover = GetComponent <IDirectionMoverComponent>(); _fieldOfView = GetComponent <IFieldOfView>(); CharacterStateMachine = GetComponent <ICharacterStateMachine>(); _currentState = wanderState; }
// 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) { _playerStateMachine = animator.GetComponent <ICharacterStateMachine>(); _mover = animator.GetComponent <IDirectionMoverComponent>(); if (_playerStateMachine.TargetObject != null) { if (_playerStateMachine.TargetObject.tag != "Enemy" && _playerStateMachine.TargetObject.tag != "Player") { return; } Vector3 direction = _playerStateMachine.TargetObject.transform.position - _mover.CurrentPosition; _mover.MoveDirection(direction); _mover.MoveDirection(Vector3.zero); } }
//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) { _playerStateMachine = animator.GetComponent <ICharacterStateMachine>(); _mover = animator.GetComponent <IDirectionMoverComponent>(); }