So I have this code that has its check and makes me fall. My question is hold can I make it so I fall down in a straight line without there being momentum. This is the code I use for falling.
///////////////////////////////////////////////////////////////////
private void HandleFallingAndLanding()
{
RaycastHit hit;
Vector3 rayCastOrigin = transform.position;
rayCastOrigin.y = rayCastOrigin.y + rayCastHeightOffSet;
if (!isGrounded)
{
if (!playerManager.isInteracting)
{
animatorManager.PlayTargetAnimation("FALLING", true);
}
inAirTimer = inAirTimer + Time.deltaTime;
playerRigidbody.AddForce(Vector3.down * fallingSpeed * inAirTimer);
}
if (Physics.SphereCast(rayCastOrigin, 0.2f, Vector3.down, out hit, maxDistance, groundLayer))
{
if (!isGrounded && playerManager.isInteracting)
{
animatorManager.PlayTargetAnimation("LANDING", true);
}
inAirTimer = 0;
isGrounded = true;
}
else
{
isGrounded = false;
}
}
///////////////////////////////////////////////////////////////////
I keep the momentum but instead I want to fall down in a straight line. Any help or suggestions?