How are your jumps done? Like what makes the player come down after they go up? It doesn't seem like there is much - or any, really - acceleration happening when you jump. The character just goes up at a set speed and then comes back down at the same exact speed they went up, just a reversed velocity. That's why people think it feels "floaty", the character doesn't appear to have any
weight.
A better idea might be to immediately ( lets assume that up is +y for this) set your y velocity to some number when the player presses the jump button, lets call it
JUMP_SPEED, and then every update, effect the y velocity with some set acceleration that we'll call
GRAVITY. Just find a number for gravity that ends up working and feeling right for how you want your jump to be.
Also it's probably a good idea to set a "terminal velocity" of sorts. I dunno how much you know about real world physics, but stuff can only fall so fast on Earth before the amount of drag the air is putting on it, causes it to not be able to fall any faster. In platform games, I think it's usually better to make this cartoonishly slow unless your playing as a golem or something, or characters feel too heavy.
So basically something like this pseudo code here
Code: Select all
jump()
{
if(canJump)
{
velocityY = JUMP_SPEED;
}
}
and then
Code: Select all
GRAVITY = some positive number
TERMINAL_VELOCITY = some negative number
update()
{
//other updateStuff
...
if(isAirborne)
{
velocityY -= GRAVITY * deltaTime;
if(velocityY < TERMINAL_VELOCITY)
{
velocityY = TERMINAL_VELOCITY
}
y += velocityY * deltaTime;
}
}
Where "detaTime" is time since the last update multiplied by whatever to get stuff moving at the speed you like.
Something like that. This will create what Sei is talking about with his lines because when you jump, GRAVITY will gradually slow your ascent until it zeros out at the top of the jump, and then you'll start falling faster and faster until you reach TERMINAL_VELOCITY.