private void Awake()
        {
            _movement      = GetComponentInChildren <Movement>();
            _playerTracker = GetComponentInChildren <PlayerTracker>();

            _playerTracker.PlayerEntered += () => { _currentZombieState = ZombieStates.Chasing; };
            _playerTracker.PlayerLeft    += () => { _currentZombieState = ZombieStates.Idle; };
        }
Example #2
0
        private void Awake()
        {
            _movement      = GetComponentInChildren <Movement>();
            _jumping       = GetComponentInChildren <Jumping>();
            _playerTracker = GetComponentInChildren <PlayerTracker>();

            _playerTracker.PlayerEntered += () => { _currentZombieState = Vector3.Distance(transform.position, _playerTracker.Position) <= _jumpThreshold ? ZombieStates.Jumping : ZombieStates.Approaching; };
            _playerTracker.PlayerLeft    += () => { _currentZombieState = ZombieStates.Idle; };
        }