public override void Enter() { base.Enter(); Debug.Log("STATE: Falling"); _animator.PlayAnimation(PlayerAnimator.FallName); _input.JumpPressed += OnJumpPressed; _input.DashPressed += OnDashPressed; _input.AttackPressed += OnAttackPressed; // reset our physics checks just in case we haven't updated since last frame _wallDetector.Detect(); _aboveWallDetector.Detect(); _groundDetector.Detect(); // alow the player a free jump if they've recently left ground (Coyote time) if (_groundDetector.LostDetectionDuration <= _data.JumpAfterFallDuration) { _lateJumpAllowed = true; } // or if they've recently left the wall if (_wallDetector.LostDetectionDuration <= _data.WallJumpAfterFallDuration) { _lateWallJumpAllowed = true; } }
public override void Enter() { base.Enter(); Debug.Log("STATE: Move Crouch"); _player.SetColliderHeight(_data.CrouchColliderHeight); _playerAnimator.ShowCrouchVisual(true); _ceilingDetector.Detect(); }
private void OnAttackPressed() { _ceilingDetector.Detect(); if (_ceilingDetector.IsDetected) { return; } _stateMachine.ChangeState(_stateMachine.GroundAttackState); }
public override void FixedUpdate() { base.FixedUpdate(); _groundDetector.Detect(); _wallDetector.Detect(); if (_wallDetector.IsDetected == false) { OnLostWall(); } }
public override void FixedUpdate() { base.FixedUpdate(); _groundDetector.Detect(); // if attack is active propel forward, if it's in wepaon data if (_weaponSystem.MeleeAttackState == MeleeAttackState.DuringAttack && _hitDamageable) { // if we're holding forward, apply additional movement based on weapon settings if (_input.XInputRaw == _movement.FacingDirection) { // forward but disable falling _movement.MoveX((_weaponSystem.CurrentMeleeAttack.PlayerForwardAmount * _movement.FacingDirection) + (_movement.FacingDirection * _data.MoveSpeed) * _weaponSystem.CurrentMeleeAttack.MovementReductionRatio, false); } else { _movement.MoveX((_weaponSystem.CurrentMeleeAttack.PlayerForwardAmount * _movement.FacingDirection), false); } } // otherwise just move according to input else { _movement.MoveX(_input.XInputRaw * _data.MoveSpeed, true); } }
public override void FixedUpdate() { base.FixedUpdate(); _groundDetector.Detect(); _wallDetector.Detect(); // if we're not grounded, but began falling, go to fall state if (_groundDetector.IsDetected == false && _movement.Velocity.y < 0) { _stateMachine.ChangeState(_stateMachine.FallingState); return; } // otherwise we're against a wall but not holding input against else if (_wallDetector.IsDetected) { _stateMachine.ChangeState(_stateMachine.FallingState); return; } // if movement is now allowed, adjust player if (_isMoveInputAllowed) { _movement.MoveX(_input.XInputRaw * _data.MoveSpeed * _data.WallJumpMovementDampener, true); } else { _movement.MoveX(_data.MoveSpeed * _movement.FacingDirection, false); } }
public override void FixedUpdate() { base.FixedUpdate(); // look for wall if (_wallDetector.IsDetected) { HandleEndOfPath(); } // look for ledge else if (!_groundInFrontDetector.IsDetected) { // if there's nothing in front but we're grounded, it's a ledge if (_groundDetector.Detect() != null) { HandleEndOfPath(); } } // look for player else if (_playerLOS.IsDetected) { _stateMachine.ChangeState(_stateMachine.PlayerDetectedState); return; } // otherwise, keep moving else { _movement.MoveX(_data.MovementSpeed * _movement.FacingDirection, true); } }
public override void FixedUpdate() { base.FixedUpdate(); _groundDetector.Detect(); // if attack is active, propel forward based on weapon data forward amount if (_weaponSystem.MeleeAttackState == MeleeAttackState.DuringAttack) { // if we're holding forward, add additional movement based on our attacks move reduction if (_input.XInputRaw == _movement.FacingDirection) { float moveAmount = (_weaponSystem.CurrentMeleeAttack.PlayerForwardAmount * _movement.FacingDirection) + (_movement.FacingDirection * _data.MoveSpeed * _weaponSystem.CurrentMeleeAttack.MovementReductionRatio); //TODO: Consider if this can be a force with momentum, once we have that capability _movement.MoveX(moveAmount, false); } // otherwise just use forward amount else { float moveAmount = (_weaponSystem.CurrentMeleeAttack.PlayerForwardAmount * _movement.FacingDirection); _movement.MoveX(moveAmount, false); } } // otherwise no xinput, so don't move in x else { _movement.MoveX(0, false); } }
public override void FixedUpdate() { base.FixedUpdate(); // if we've reached a wall if (_wallDetector.IsDetected) { // turn around TurnAround(); // detect again in new direction to reset _wallDetector.Detect(); } // or a ledge else if (!_groundInFrontDetector.IsDetected) { // if there's no ground in front, but ground beneath, it's a ledge if (_groundDetector.Detect() != null) { TurnAround(); // detect in new direction to reset _groundInFrontDetector.Detect(); } } // otherwise, keep moving else { _kinematicObject.MoveX(_crawler.MovementSpeed * _kinematicObject.FacingDirection, true); } }
public override void Enter() { base.Enter(); _playerInRange.StartDetecting(); // ensure we detect right before assigning to avoid a frame skip _objectToChase = _playerInRange.Detect().transform; Debug.Log("Object to chase: " + _objectToChase != null); }
public override void FixedUpdate() { base.FixedUpdate(); // using the dash in update so that we don't trigger a state change while we're still entering _groundDetector.Detect(); // otherwise use dash values _movement.Move(_dashDirection * _data.DashVelocity, false); }
public override void FixedUpdate() { base.FixedUpdate(); _groundDetector.Detect(); // if we're not grounded, but began falling, go to fall state if (_movement.Velocity.y <= 0 && _isJumpLocked == false) { _stateMachine.ChangeState(_stateMachine.FallingState); return; } _movement.MoveX(_input.XInputRaw * _data.MoveSpeed, true); }
public override void FixedUpdate() { base.FixedUpdate(); _aboveWallDetector.Detect(); _movement.MoveY(_data.WallClimbVelocity); if (_aboveWallDetector.IsDetected == false && _data.AllowLedgeHop) { // space above wall, if wall in front of us it's an upper ledge! if (_wallDetector.Detect() != null) { _stateMachine.ChangeState(_stateMachine.LedgeClimbState); return; } } }
private void HandleEndOfPath() { // idle if specified if (_data.IdleOnPathEnd) { _stateMachine.ChangeState(_stateMachine.IdleState); return; } // otherwise turn and continue else { _movement.Flip(); _movement.MoveX(_data.MovementSpeed * _movement.FacingDirection, true); // immediately detect new direction _groundInFrontDetector.Detect(); _wallDetector.Detect(); } }
public override void FixedUpdate() { base.FixedUpdate(); _groundDetector.Detect(); }