Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Problem with jumping

Author
Message
Cek
13
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 25th Apr 2013 18:22
Hello all!

I'm having an issue with my game. For some reason, it will not let the model jump. I've gone through and tried to see what the problem is, but I cannot figure it out. Does anyone have an idea what the problem may be?



Thanks a bunch!
-Cek
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 26th Apr 2013 03:32 Edited at: 26th Apr 2013 03:34
What you want to do is probably this:

This code must furthermore be applied in each main loop cycle, not just when hitting the jump key as you currently have it.
Also, you should decrease your acceleration so something like
should probably be better. If you don't decrease your acceleration you will keep going up if it is greater than the gravity.

You should also be aware that your code would not be very safe; there is nothing stopping you from going through the walls / floor / roof. In fact if you threw that line above right into your main loop you would immediately fall through the floor
Also the built in collision functions are pretty bad. They might do for this kind of application (I haven't used them in years, can't remember) but you would really do yourself a favour by getting a third party plugin for handling collisions. For example Sparky's collision plugin (search on these forums) does a great job and is available for free.


"Why do programmers get Halloween and Christmas mixed up?"
Cek
13
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 26th Apr 2013 18:13
Thank you very much for responding! Taking your advice, I was able to fix both problems. I'm going to take a look at the Sparky's collision plugin because, like you said, the player falls right through the floor.
Cek
13
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 26th Apr 2013 18:33
Also, should I be doing something like this with the code that you have provided?

Cek
13
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 30th Apr 2013 18:36
Hello again!

Thank you very much for your help. I was able to solve the issue with the jumping, thanks to your help but now I'm having a problem with the collision box.

Like you said, he falls through the floor at random times while trying to jump. I've looked through the code trying to figure out what it might be but have not been able to solve it. I'm curious to whether the collision box of the floor needs to be reconfigured or if it's something else entirely.

Login to post a reply

Server time is: 2026-07-07 02:17:14
Your offset time is: 2026-07-07 02:17:14