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.

Newcomers DBPro Corner / jumping script error

Author
Message
TrueMOD
21
Years of Service
User Offline
Joined: 12th Sep 2003
Location:
Posted: 3rd Aug 2007 02:13
Ok while searching this forum I found a nice jumping script that I wanted to adept to my game.
This is the code I found:



so now I tried this and liked the jumping behaviour...with a few modifications its easy to adept to any game...but...after merging the code with mine im falling to the top...not downwards...and when I jump I jump downwards...there must have been a lil mistake while converting the code to fit in mine but I cant find it.



I know its kinda confusing searching some other ones code but I could really need the help since its been a long time I used DBPro. Also I left in my old testing code and marked it out with rems and also stated where I added the code from the upper code snippet.


Thanks in advance


Ben
Tecnuro Entertainment LTD
18
Years of Service
User Offline
Joined: 28th Oct 2006
Location: London, U.K
Posted: 9th Aug 2007 22:20
I hate coding jumps because they really can be a pain - there's an almost endless frontier of how realistic you can go with them and theyre so tricky to get right.

I'm a messy, simple coder but I don't see any other help here, so I'll give it a try.



1. You have an unconditional expression which says that grav#, (-0.2), should always be subtracted from yvel#:

Quote: "`Acceleration due to gravity
yvel# = yvel#+grav#"


This is impacting on ypos#:

Quote: "ypos# = ypos#+yVel#"


Thinking about how fast this expression is be processed, even if you do jump, it's likely your jumping power will be nullified as soon as you release space bar.


2. Another (lazy but sufficient) method:

1. Set a variable let's say jumpheight# to 0 before the loop

2. Set a maximum value for the jumpheight using an expression containing one inequality:



3. Make a trigger condition for the state of the player:



4. Decrement the y position of the player higher than gravity so long as jumpheight#>0 and playerjump#=0

5. Set a global gravity level by decrementing the objects y position until it is firmly on the ground



6. Once the entity is back on the ground (whatever y value that may be) you reset your all your variables to 0.

Kez: Legacy of the Flame

Login to post a reply

Server time is: 2024-11-25 13:35:02
Your offset time is: 2024-11-25 13:35:02