Ejemplo n.º 1
0
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        _direction += SteeringBehaviour.Seek(_playerStateMachine.TargetLocation, _mover.CurrentVelocity, _mover) * Time.deltaTime;

        if (!enableYDirection)
        {
            _direction.y = 0;
        }

        _mover.MoveDirection(_direction);
    }
Ejemplo n.º 2
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)
    {
        _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);
        }
    }