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 / Best way to make an object jump in a 3d program

Author
Message
cheese pwner
16
Years of Service
User Offline
Joined: 26th Oct 2008
Location:
Posted: 9th Jul 2011 16:08
Im working on a simple 3d program, where an object jumps when the spacebar is hit

My current code is :


this is simple movement code, simple camera following code, the z2# is to change the angle at which you look at the object, then some basic collision detection (there are no other objects on the matrix yet, i removed them earlier on).

i still am unsure of how to make an object jump, then come back down in one fluid motion. Any help is appreciated thanks
Bulsatar
13
Years of Service
User Offline
Joined: 19th Apr 2011
Location:
Posted: 9th Jul 2011 18:17 Edited at: 9th Jul 2011 18:18
For your object, you could create a udt so that way it has a jump indicator and where the starting jump position is. Then you can have a pre-determined amount that the object will jump up before it comes back down. This is the simplest, if you want more realism you will have to get some simple physics involved.

easy example:

All of this above is off the top of my head and I am uncertain of the syntax, but it should work. For more realism in the jump, you can give your characters and world gravity and mass and do some basic F=G*(M*m)/r^2 and then covert the force to an acceleration, but I am pretty sure that there is code out there all ready established to mimic that.
Webber
13
Years of Service
User Offline
Joined: 27th May 2011
Location:
Posted: 18th Jul 2011 08:32
Jumping
I love making stuff with jumping!
I used to have the same problem, now I'm an expert on jumping.
The trick is to add some more variables.
Here is a perfect example on how to make things jump.



I like games, and stuff.
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 19th Jul 2011 18:39
Good one Webber Let me make you a master at jumping It is possible to squeeze out one more variable:



TheComet

Webber
13
Years of Service
User Offline
Joined: 27th May 2011
Location:
Posted: 25th Jul 2011 04:53
I dono bout dat, its an important variable for collision purposes.

Its possible that it will make the player boble/shake on the ground without it. Kinda like an earth quake.
But there are ways of fixing the collision glitch.
Unfortunately other side effects usually occur, and depending on the numbers you use, the character will fly instead of fall.
And in some cases the character will forget to fall.

Because of the parabolic curve when the character jumps, at one point in time the gravity does equal 0.
So you need to detect the collision of the floor, not the speed of the gravity.
Also depending on the complexity of your collision, the gravity might still exist when on a slope.
Or if you want to get real fancy you might want to make your character do wall jumps.

And if you tested your code, you would have noticed that you forgot to get rid of an endif command.
Sometimes I make mistakes like that too.
It is possible to get rid of another variable, but depending on the game that you are making, it isn't the best thing to do.
One variable isn't going to change the speed of the game very much.
But if you're really concerned about the variable you can declare it as a boolean.
Not a bad idea.
After all it only ever equals 0 or 1.



Looks like we're all masters of jumping now.


If only I was a master with object collision.
I have an awesome platform engine on the code base.
Its listed in 3D effects, its called "Boxes and More Boxes".
Its a great example of jumping, collision, and other cool stuff.
Very unique, I don't even think it uses any collision commands.
I should probably update it though.
To bad that I can't figure out how to make such nice collision with angles.

I like games, and stuff.
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 25th Jul 2011 12:29
Hah, yeah, I see your point If you need help with collision, I have an example lying around that uses sparky's. You might be interested

Oh, and this:

Quote: "After all it only ever equals 0 or 1."






TheComet

WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 26th Jul 2011 05:19
Just popped in and noticed you were talking about booleans.

Try this:



It will give the result as 255.

A boolean isn't a proper boolean in DBPro. So be careful with it.

The only way around this is to use something like this:



Warning! May contain Nuts!
Webber
13
Years of Service
User Offline
Joined: 27th May 2011
Location:
Posted: 10th Aug 2011 20:00
That's really weird, I never noticed that. Is that a glitch?
Booleans have the same values as a byte.
Or is a byte not a proper byte in DBP?
If you look up the value of a boolean in DBP it clearly says that it's a value between 1 and 0.
Well just don't subtract a boolean with a value of 0 or add to a value of 1.

I like games, and stuff.

Login to post a reply

Server time is: 2024-11-22 18:59:43
Your offset time is: 2024-11-22 18:59:43