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 / Any suggestions on making your character jump?

Author
Message
anakin
21
Years of Service
User Offline
Joined: 23rd Jun 2003
Location:
Posted: 30th Jun 2003 22:56
I'm currently working on a 3rd person perspective game but I guess the answer for this question is independent of that fact... I wish to make my character jump, I've considered different jumping techniques like the ability to control one's self to some extent in the air VS a jump that is exactly the same each time (same distance traveled and no control in the air). If someone could share a code snippet and/or a small idea behind what I should be looking for when considering jumping techniques, I'd appreciate it.

Thanks in advanced,

Anakin
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 30th Jun 2003 23:26
I have one suggestion : make the char move up, then down.

Humour aside, that's what jumping is; so when programming it keep that in mind.

There are a few ways to go about jumping. Two are:

- Check if the user has pressed jump. If so, start a timer and every loop move the char up a bit, when you get half way through (and over) the alotted time, move the char down a bit every loop (by the same amount).

- Have a 'visual' character object, and have a dummy, invisible object that the player will control. Every loop position you visual char and a curvevalue() calculated position (heading towards the dummy). Also have gravity acting on the dummy. When you pres the dummy, move it up by a set amount, and every loop the visible char will glide up to the top point, and since gravity is acting on the dummy you char will also glide down.

That may sound complicated, so I'll post a snippet soon.

You are the th person to view this signature.
GRAVITY: I fought the law but the law won
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 30th Jun 2003 23:37
Here you go. This snippet assumes the ground height is 0, your game may require otherwise.

You are the th person to view this signature.
GRAVITY: I fought the law but the law won
anakin
21
Years of Service
User Offline
Joined: 23rd Jun 2003
Location:
Posted: 1st Jul 2003 03:56
Cool, Ill try out both methods...

Thanks,

Anakin
anakin
21
Years of Service
User Offline
Joined: 23rd Jun 2003
Location:
Posted: 1st Jul 2003 09:02
I tried both methods... the problem I had with the dummy as that if the dummy gets caught or clipped above or below the real player then the player cannot jump... The problem with the timer is that you dont know when the player will land... I mean if the player jumps down... and he is falling.. after the timer finishes he can jump again...

One way I thought of doing it is to see if the character is moving up or down... maybe checking Y then checking Y and compare them to see if there has been a change... if the player is moving up or down then they should be able to jump, since jumping in mid air isnt allowed... but then this could run into a problem when the character is running down a mountain side... and how would you test to see if the player was touching the ground??

If you or anyone else has ideas or maybe Im missing something I'd appreciate the information.

Thanks in advance,

Anakin
haggisman
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 1st Jul 2003 12:14
You could just use a simple equation of motion to calculate the jumping like so...



project: light/obscurance mapper (85% done)
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 1st Jul 2003 22:40
Quote: "and how would you test to see if the player was touching the ground?? "


Well if you're using a matrix that's easy. Check out the get ground height() function.

You are the th person to view this signature.
GRAVITY: I fought the law but the law won
anakin
21
Years of Service
User Offline
Joined: 23rd Jun 2003
Location:
Posted: 2nd Jul 2003 05:27
Thanks for the post haggisman Ill check it out...

David89-

Yea but unfortunately Im using levels that I make in CShop...

Login to post a reply

Server time is: 2024-09-20 13:41:29
Your offset time is: 2024-09-20 13:41:29