Hey all!
So in my platformer code, my character jumps just fine. However, when he just walks off an edge, he falls a lot faster than when he is jumping. I am implementing my jumping by having a jumpForce variable, a gravity variable, and then constantly adding the gravity to the player's movement:
//apply the gravity
movement.y += gravity;
//check for input
if (Input.IsActionPressed("moveRight"))
{
movement.x = moveSpeed;
isFacingRight = true;
}
else if (Input.IsActionPressed("moveLeft"))
{
movement.x = -moveSpeed;
isFacingRight = false;
}
else
{
movement.x = 0;
}
if (IsOnFloor())
{
if (Input.IsActionJustPressed("moveJump"))
{
//set the jump force
movement.y = -jumpForce;
}
}
MoveAndSlide(movement, upDirection);
Is there a better way to fo about this so that the player doesn't just fall quickly off of the platforms?
Thank you!