Jump to content
  • Advertisement
Sign in to follow this  
Show

Need help: 2D Jump

This topic is 4007 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What's the correct way of implementing jump? Right now if i hold the forward key, my character will run forward. But if i make my character jump while still holding the forward key, it will jump but it will stop going forward after it lands. Thx

Share this post


Link to post
Share on other sites
Advertisement
We will need to see some code. How are you checking for key presses? You will most likely do something along the lines of:

jump key pressed?
add some number to the jump variable.
add the jump variable to the players y-coordinate.
decrement jump variable.

Share this post


Link to post
Share on other sites
If the forward key goes down, set a moveForward boolean to true, and as long as that boolean is true, move forward (if allowed, of course). If the forward key goes up, set that boolean to false. That approach should solve the problem.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!