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 / Another question....FPS Jumping.

Author
Message
Ragnarok89
20
Years of Service
User Offline
Joined: 27th Jun 2004
Location: Look behind you! Ahhhh!~
Posted: 4th Oct 2005 03:41
Yes, I have looked through a bunch of posts and I never found a way to jump with my code.



All the media is included with DarkBASIC (Though I think the wall texture was renamed that I use.) Anyways...if anyone can figure out how in the world I can get this stupid thing to jump...please..PLEASE help Or if you dont want to give me the code...lead me in the right direction of HOW to code it. Thanks
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 4th Oct 2005 04:44
Arrrgghhh!

I hate long snippets of code - to be able to answer a question, you need to follow the code and understand what's going on and with long snippets, it just takes far too long to read - especially at 3am in the morning...

I would say that 90% of that code is irrelevant to your question and could have been removed before you posted it.

Anyway, I've not studied your code, but if you are using the camera in an FPS, then jumping is nothing more than altering the Y position of the camera.

If jumping from standing still, in real life, the knees would bend and eye level drops slightly then you quickly accellerate upwards, before gravity takes effect and pulls you back down again.

In programming terms, you would decrease the Y value of the camera to the lowest position then quickly increase the Y value (velocity) until the starting Y position is reached - at which point you begin to decrease the velocity until you reach the peak of the jump and you momentarily stop.

You then apply accellerated downwards velocity (negative values) until you hit the ground.

This is done using procedures that you can call to do a bit of jump movement at a time - so everything else in your game doesn't grind to a halt while you are jumping.

One variable would contain the camera's Y position and another would contain a 'velocity' value. Each time around the loop you would add velocity to the camera's Y position then increase or decrease the velocity variable depending on whether the jump was in an accellerating or decellerating phase.

At the top of the jump, when velocity decreases to zero, you continue decreasing it and as it becomes a negative value, adding it to the camera's Y position will result in the camera moving down.

Keep increasing the negative value and it will speed up the rate of fall until you hit the ground - just like a falling object gathers speed.

And that's it!

Jumping onto things requires extra calculations and jumping while running, you just leave out the initial 'dip' of the camera, but essentially, the method is the same.

With third person views, you apply the same logic to the object rather than the camera.

Phew! I think it would have been quicker to just type in the damn code!

TDK_Man

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 4th Oct 2005 05:04 Edited at: 4th Oct 2005 05:06
To give you a bit more of a guide, I just wrote a bouncing ping pong ball demo. It's just one way to do it.

If you look at the code, it should give you some ideas on which way to go with regards to positioning an object (or the camera) using a velocity variable...



TDK_Man

Ragnarok89
20
Years of Service
User Offline
Joined: 27th Jun 2004
Location: Look behind you! Ahhhh!~
Posted: 4th Oct 2005 05:47
Lol. Thanks that kinda clears stuff up. I know how physics work, but if you would have read the code you would see that something in there is messing up the jumping lol. But for the most part read this...I think i figured it out Thanks.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 4th Oct 2005 15:49
Sorry about that - I wan't sure at what level you were at with the jumping side of things as your jumping code just said:

Jumping:
Return

which wasn't a lot to go on!

TDK_Man

Login to post a reply

Server time is: 2025-05-22 15:17:16
Your offset time is: 2025-05-22 15:17:16