Page 1 of 1

Player jumping increases with speed

Posted: Wed Jul 24, 2013 7:21 pm
by lieudusty
Hi! I'm making an endless running side scrolling game and the jumping jumps too far when the speed is increased. The speed of the game is increased overtime and the jumping jumps further out.

For example at lets say at speed 1 when the player jumps the player moves 100 px, but at speed 5, when the player jumps the player moves 500 px. How can I make the player only jump a certain distance regardless of the speed?

Thanks in advanced for the help! :)

Re: Player jumping increases with speed

Posted: Wed Jul 24, 2013 7:25 pm
by Davidobot
I haven't looked at your code but, if you are using dt and you multiply it by the speed, make sure to divide it again by the speed when you are jumping.

Re: Player jumping increases with speed

Posted: Wed Jul 24, 2013 7:30 pm
by lieudusty
Davidobot wrote:I haven't looked at your code but, if you are using dt and you multiply it by the speed, make sure to divide it again by the speed when you are jumping.
Well when the game speeds up, I add the speed to the scrolling so it speeds up the map movement. But, that results in the jumping to jump further.

Re: Player jumping increases with speed

Posted: Wed Jul 24, 2013 7:33 pm
by Davidobot
lieudusty wrote:
Davidobot wrote:I haven't looked at your code but, if you are using dt and you multiply it by the speed, make sure to divide it again by the speed when you are jumping.
Well when the game speeds up, I add the speed to the scrolling so it speeds up the map movement. But, that results in the jumping to jump further.
That's because, as you are in the air, the map moves under you. You can try dividing the jump speed of the player by the speed?

Re: Player jumping increases with speed

Posted: Wed Jul 24, 2013 7:35 pm
by micha
In your place, I personally would leave it like it is, because this is the physically correct behavior.

If you still want to change it you have two options: Either change the jumping height (by making the initial jumping velocity smaller) or increase gravity. Since the games speed increases you have to decrease the air time of the player to keep the jumping distance constant.

Re: Player jumping increases with speed

Posted: Wed Jul 24, 2013 7:37 pm
by lieudusty
Davidobot wrote:
lieudusty wrote:
Davidobot wrote:I haven't looked at your code but, if you are using dt and you multiply it by the speed, make sure to divide it again by the speed when you are jumping.
Well when the game speeds up, I add the speed to the scrolling so it speeds up the map movement. But, that results in the jumping to jump further.
That's because, as you are in the air, the map moves under you. You can try dividing the jump speed of the player by the speed?
Ah ok, I just added the map speed to the jumping velocity and now the jumping is relative to the map speed. Thanks! :)

Re: Player jumping increases with speed

Posted: Wed Jul 24, 2013 7:42 pm
by lieudusty
micha wrote:In your place, I personally would leave it like it is, because this is the physically correct behavior.

If you still want to change it you have two options: Either change the jumping height (by making the initial jumping velocity smaller) or increase gravity. Since the games speed increases you have to decrease the air time of the player to keep the jumping distance constant.
After I fixed it, it seemed a bit unnatural so I just kept it like it was :)