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.

Work in Progress / Phy Jump - Yes, you can finally just call jump() [sorta

Author
Message
BearCDP
15
Years of Service
User Offline
Joined: 7th Sep 2009
Location: NYC
Posted: 12th Oct 2009 06:38 Edited at: 28th Dec 2009 09:42
BearCDP's phyJump


Update
Fixed the issue with ray cast distance, also added ray cast check for bumping your head on something above.
New download: https://forumfiles.thegamecreators.com/download/1929546

Still no luck getting my example to work with Vista/7, but maybe that's because the machines I've tested don't have DirectX 9 or something? If you can integrate the functions into your project and get it work on Vista/7, post here and let us know!
----------------------------------------------------------------

Hey everyone, I started working on a game in GDK, and found the little issue with getting a good jumping implementation with Dark Physics. I read that many people have just written their own, or applied force directly below a character that was defined as a regular rigid body.

That seemed like a good way to do it, but as I read TGC's schpiel on their reason for including a character controller in the first place--I began thinking that I may as well just do the work and put my high school physics skills to use.

With BPJ_phyJump() you can add your object's ID to a list of "jumpers" that each have an associated gravityEnvironment (which you can also create multiples of and reference them using the typical DB ID number system). You can then call BPJ_updateAllGravityEnv() to update the gravity for all your gravity environments, or you can update them individually with BPJ_updateGravityEnv(id). Alternatively, there is a BPJ_updateAllTimedGravityEnv(timeFactor#) and BPJ_updateTimedGravityEnv(id, timeFactor#) if you've chosen to implement timing in your game. Just pass your timeFactor#, and set all your values according to whatever timing scale you're using, and it will scale the gravity's effect based on your timeFactor# value.

You can create either Box or Capsule gravity. Box is more lightweight of course, and more clean-cut in determining how to handle a player hanging around an edge. There is a very clearly defined point when the player is and is not on the edge.

On the other hand, capsules have a sort of middle ground where a player may either be sliding off the edge, or sort of just hanging there in lala land. If a player is in this state, then a function called BPJ_reactToCliffHanger() is called. This function is in a separate include file, because I have a provided a basic implementation that will just scoot the player off the edge, but in case you want to have it do something else that opportunity is available.

Any C&C is of course appreciated. I'm using one ray cast per character as part of the gravity check on each loop. I haven't used ray casting since Nuclear Glory v2 on DBC, so I'm not as familiar with how it affects performance. Anyone have any recommendations or reassurances? Also, if you see anything weird please let me know. Until recently the cliffHanger implementation would make the player slide along the edge of the platform and fly off into oblivion.

Here's a youtube video: http://www.youtube.com/watch?v=fZqPHnac2YA

Here's my original thread: http://forum.thegamecreators.com/?m=forum_view&t=158090&b=30

Here's the download: https://forumfiles.thegamecreators.com/download/1871840

And here's your screenshot, you addicts . . .
Not quite as informative as the video, but I did manage to capture the player in the midst of a "cliff hanger" moment, as indicated by the awkward text in the middle of the screen:



Attachments

Login to view attachments
Slooper
21
Years of Service
User Offline
Joined: 13th Feb 2003
Location: Sweden
Posted: 20th Oct 2009 23:14
Damn it crashes, kinda annoying as i have waited for this to be released ^^


You never fail, only make mistakes.
scutheotaku
14
Years of Service
User Offline
Joined: 9th Dec 2009
Location:
Posted: 11th Dec 2009 04:46
First of all, sorry to bump this - I know this is a couple of months old. I really like your code here, but I'm having some problems with it. All I have done so far is try to add 2 more "floor" blocks for "theColonel" to jump on. After he jumps on to the first one that I added (which is below the upper floor you add), he can no longer jump until he moves off of that floor on to another one. The second floor I added is higher, and I can't even get to it because of the problem with the first floor. What do you think the problem would be?

Here is my code for the setupscene() part (since that's the only part I changed)-


Any ideas?

PS : Sorry if that was confusing - I'm tired
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 26th Dec 2009 18:32
BearCDP,
Are you still working on a DarkGDK version for this? It would really help out.

Thanks

BearCDP
15
Years of Service
User Offline
Joined: 7th Sep 2009
Location: NYC
Posted: 28th Dec 2009 09:37
Hey guys, I'm happy that you've been able to find use for this. I haven't totally abandoned a GDK version, but it's not quite a priority for me right now.

Scutheotaku, I see what you mean. If you noticed, the jumpTimeElapsed value kept increasing and the preJumpYPos# value never updated once you landed on the upper platform. Turns out the ray cast did hit the upper platform, but Phy Get Ray Cast Distance() decided to return the lower platform's distance instead of the upper one's. Changing the ray cast call to "Phy Ray Cast Closest Shape" fixed the problem, since there seems to be no way to loop through ray cast hits (even though Phy Ray Cast has a return value . . . weird stuff).

Anyway, I made the correction, and also added another ray cast to check if the player bumps into the ceiling. It's the same value as a downward ray cast check, so keep the ray cast distance# value relative to the center of your models. If I or you guys find a need it's easy to change to a separate check for top and bottom distances.

Code is attached. I'll also update the top link.

Attachments

Login to view attachments
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 13th Jan 2010 22:06
Bear, I don't need this but I just thought I'd share an idea:

Would offsetting the player's centre of mass using the PHY SET RIGID BODY MASS OFFSET LOCAL to a point either directly in front of the capsule or possible further out fix the cliff hanging issue? You should try it out if you haven't yet, it'd make things easier than adding pushes to the character. I have my doubts as DP always gets screwy when you try to use most of the rigid body commands on character controllers, but its worth a try either way.
Maple Engine
14
Years of Service
User Offline
Joined: 26th Jan 2010
Location:
Posted: 26th Jan 2010 20:05 Edited at: 27th Jan 2010 16:06
Hello, im trying to use this streight out of the box (i do have dark physics) but im getting a weird error:

Compilation Failed. Could not understand command at line 46.

line 46: Phy Set Character Controller Displacement theColonel, 0.0, 0.0

i havent changed anything?
i am using someones(forgoten the name) help thingy and for that i needd to replace the keywords file but would that make a differance?

EDIT:
just read throuch your post and i have vista, do you think thats why?


Ok, i'v kinda got it working but now whene i run anything with darkphysics it comes up with the nvidia drivers page, i had this problem whene i first got DP but i forgot how i fixed it

Any idias?

Lewis Hallam

http://maple-engine.co.nr/
a 3d rpg engine for dbpro
BearCDP
15
Years of Service
User Offline
Joined: 7th Sep 2009
Location: NYC
Posted: 22nd Mar 2010 08:53 Edited at: 22nd Mar 2010 08:54
Hey everyone! I totally thought I had email notification turned on for this one. Oh well, now I do.

@Ruccus
That's a great idea! The pushing solution always bothered me, but it seemed like the most elegant way at the time. When I use this for my own stuff, I'll most likely stick with box controllers, the capsule was kind of a headache.


@Lewis
I feel your pain, I've been testing it out on various computers with 7 or Vista, and it seems like it's difficult to configure them to run a compiled version correctly. Maybe it's a DX10 vs DX9 issue? Sadly I don't have Vista or 7, so when I go home for the summer, I'll see if I can fiddle around with a friend's computer to figure out what the issue is.

I remember having that same problem with the drivers page as well. Part of the solution involved downloading and installing the drivers like it wanted, but I can't remember what else I did. I'll post back in here once I get iron out a couple more kinks and try out Ruccus' idea.

Login to post a reply

Server time is: 2024-11-24 14:54:36
Your offset time is: 2024-11-24 14:54:36