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 Discussion / Jumping Problems

Author
Message
Blazer
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: United States
Posted: 19th Jan 2003 23:02
I don't see why this wont work heres the code:

if jump=1 and playergrav#=0.0 then playergrav#=2.0

if object position y(1) > get ground height(1,x#,z#)+19 then playergrav#=playergrav#-0.1

if object position y(1)
Blazer
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: United States
Posted: 19th Jan 2003 23:06
strange the forums cut me off... oh well


if jump=1 and playergrav#=0.0 then playergrav#=2.0

if object position y(1) > get ground height(1,x#,z#)+19 then playergrav#=playergrav#-0.1

if object position y(1) <= get ground height(1,x#,z#)+1 then playergrav#=playergrav#

y#=y#+playergrav#


The code should make the object stop at the matrix or below, then when I press a button that makes the gravity = 2 it should slowly decrese, then stop at the matrix again. But instead the object keeps falling through the floor. What am I doing wrong plese help!

Also I think if I jump up on an object with this code and try to jump again it will only let me go 2 up from the matrix insead of the object. Is there a way to get ground height from the matrix AND objects. Plese help
Dr DooMer
22
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: United Kingdom
Posted: 22nd Jan 2003 03:26
"then playergrav#=playergrav#"?

See a problem?

If not, try this: "then playergrav#=0"

You'll probably kick yourself when you realise what you've done wrong. Don't worry mistakes like this happen to all of us...

Also, just for your information, not to tell you you're wrong or anything, but gravity is a (practially) constant variable, and velocity, which you've called playergrav#, is the rate at which an object's speed of descent changes. I'm just mentioning it because it confused me a little bit when I first read your code.

Anyway, hope this helps!

"I am a living, thinking entity who was created in the sea of information."
Blazer
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: United States
Posted: 22nd Jan 2003 05:26
thx I got it, but theres still a problem, he jumps off the ground, so if he jumps on an object (I coded that ) he jumps the same height as the ground is there an (easy) way to code this?
Hamish McHaggis
22
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 22nd Jan 2003 22:58
You mean he cant jump when on the object? You could try making it so that the player_grav# is decreased all the time and set to 0 when you hit the matrix or the object and set to 10 or something when you press the jump key.
Is that your problem?

Yum! Yum! Yum! Yum!
Blazer
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: United States
Posted: 23rd Jan 2003 01:30
nope, that works, thx

Login to post a reply

Server time is: 2025-05-16 19:41:00
Your offset time is: 2025-05-16 19:41:00