Edit: I fixed the problem by making jumpvelocity the one that is modified and added onto, and yvelocity just equal jumpvelocity * t. This is what I have right now:
if (GUI->Space && grounded){
jumpvelocity = -185.f * 2 / gravity;
grounded = false;
}
if(!grounded ){
if(jumpvelocity < terminaly){
jumpvelocity += 185.f * t * 4 / gravity;
yvelocity = jumpvelocity * t;
}
else{
jumpvelocity = terminaly;
yvelocity = jumpvelocity * t / gravity;
}
}
else{
yvelocity = 0.f;
jumpvelocity = 0.f;
}
Thanks for the help.
I am trying to get my gravity to work. The code I have so far is
if (jumpvelocity < 0){
yvelocity = jumpvelocity * t *2/gravity;
jumpvelocity += 185.f*t * 2 / gravity;
}
else if(!grounded ){
if(yvelocity < terminaly)
yvelocity += t / gravity;
else
yvelocity = terminaly;
}
Gravity scales upwards, the higher making falling and jumping slower. It's default value is 1. Jumpvelocity is set to 185 when the player wishes to jump. My problem is that you fall slower at a slower framerate, but you jump at the same speed as if it was a higher framerate. How would I make it frame independent? T is delta time.

jumpvelocitywith its previous value when updatingyvelocity, giving you an accuracy error that will get worse at lower framerate. What you callyvelocityshould actually beymovementsince it's a velocity multiplied by time. You are updatingjumpvelocitywhen the character no longer touches the ground, which has no physical meaning. Your check forterminalyis done before updating, causingjumpvelocityto be greater thanterminalyand worsens at lower framerates. – Sam Hocevar Oct 19 '11 at 11:27