|
|
|
|
|
|
public class DescendAction : StateAction |
|
|
|
{ |
|
|
|
//Component references
|
|
|
|
private Protagonist _characterScript; |
|
|
|
private Protagonist _protagonistScript; |
|
|
|
|
|
|
|
private float _verticalMovement; |
|
|
|
private const float GRAVITY_MULTIPLIER = 5f; |
|
|
|
|
|
|
public override void Awake(StateMachine stateMachine) |
|
|
|
{ |
|
|
|
_characterScript = stateMachine.GetComponent<Protagonist>(); |
|
|
|
_protagonistScript = stateMachine.GetComponent<Protagonist>(); |
|
|
|
_verticalMovement = _characterScript.movementVector.y; |
|
|
|
_verticalMovement = _protagonistScript.movementVector.y; |
|
|
|
_characterScript.jumpInput = false; |
|
|
|
_protagonistScript.jumpInput = false; |
|
|
|
} |
|
|
|
|
|
|
|
public override void OnUpdate() |
|
|
|
|
|
|
//Cap the maximum so the player doesn't reach incredible speeds when freefalling from high positions
|
|
|
|
_verticalMovement = Mathf.Clamp(_verticalMovement, MAX_FALL_SPEED, MAX_RISE_SPEED); |
|
|
|
|
|
|
|
_characterScript.movementVector.y = _verticalMovement; |
|
|
|
_protagonistScript.movementVector.y = _verticalMovement; |
|
|
|
} |
|
|
|
} |