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.

Dark GDK / Ok, need some help with gravity and collision

Author
Message
puppyofkosh
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 6th Jan 2009 01:46
Alright, sorry for asking so many dumb questions, or questions that may seem dumb, whatever.

So I have collision fully working, and my idea for gravity was to constantly check for collision with the map, move the player down at an increasing rate, and if the player did collide with the map, stop them.

Unfortunately my little idea didn't work.

Here's the function I called :




To be blunt: It doesn't work. I do fall at an increasing rate, but I go right through the floor. Without gravity, I can just fly down, hit the ground and not go through.

I also displayed "Collide" during the whole program, and when I hit the ground, it was still 0.

Any ideas?

Thanks.
SunDawg
19
Years of Service
User Offline
Joined: 21st Dec 2004
Location: Massachusetts
Posted: 6th Jan 2009 03:20
You'll have to show how Collide is assigned its value. The problem doesn't seem to be with this code.


My site, for various stuff that I make.
puppyofkosh
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 6th Jan 2009 03:22


Here ya go.
Bejasc3D
16
Years of Service
User Offline
Joined: 17th Aug 2008
Location: Down Under
Posted: 6th Jan 2009 13:10
Umm.. ok, I dont even do Dark Basic ect.. So this is probably fine, but, just loking at it


//if they are colliding
if (Collide > 0);

Should one of them be there?

puppyofkosh
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 6th Jan 2009 22:02
Yeah, I have that on the sixth line of the second code I posted...
Or am I not interpreting you correctly?
entomophobiac
22
Years of Service
User Offline
Joined: 1st Nov 2002
Location: United States
Posted: 6th Jan 2009 23:28
Might just be the order of things. Are you checking "Collide" before you apply gravity? The order your code is executed is extremely important. This can often be the case when it works fine without a new snippet of code.
puppyofkosh
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 6th Jan 2009 23:48
Yeah, I am. I will remember that though.

In theory it should work, I believe, however Collide does not become anything other than 0 when I hit the ground (and then go through), so could it be the command I am using?
Bejasc3D
16
Years of Service
User Offline
Joined: 17th Aug 2008
Location: Down Under
Posted: 7th Jan 2009 01:54
With what i said, ITs highly unlikely true,

But
On BOTH of your codes, The sixth line, is missing a ";"
I just noticed that its on every other one, and not that one.


Keep in mind i know nothing of coding.. so no one hate me plese

puppyofkosh
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 7th Jan 2009 02:12
good observation, but if statements, for loops, the start of functions and some other things don't need the ; =).
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 7th Jan 2009 02:47
but using them is more punctual

for(int i;i<5;i++){
// blah
};

That has been the way for years - but people just don't use them. It doesn't matter - but for me it's a reminder I'm in C++ versus C# - as C# doesn't allow semicolons in some spots.

Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 7th Jan 2009 02:49
What? People don't put the semicolons in their for statements? What the crap?
puppyofkosh
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 7th Jan 2009 02:59
lol, I've never done that.

Anyway, any of you think you know what it is/think you can help?
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 7th Jan 2009 03:27
First of all, this could be changed to get your desired effect...?



to this, to retain the Gravity variable.

Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 7th Jan 2009 03:38 Edited at: 7th Jan 2009 03:41
I use Sparky's for DBPro, not for DGDK, but I assume they're virtually the same thing.

1) Did you setup your objects (including the world object) with a specific group number using sc_setupobject?

2) Are you setting the OldX/Y/Z variables to the object's position before movement and the X/Y/Z variables to the object's position after movement?

3) Did you use the sc_allowobjectscaling command? I'm not sure if it's needed but it's worth a try .

4)Do you use sc_updateobject? (I see you do in the code you posted but I figured I'd ask anyway...)

5) Also, you may want to exclude the object that you are checking collision for from the collision check using the ExcludeObject parameter at the end of the SC_SPHERESLIDE command.

puppyofkosh
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 7th Jan 2009 03:56
I put all of that in, but now when I fall through, I go through a large giant green sphere...nowhere in my program is there a giant green sphere rendered...

Thanks for all the help.
puppyofkosh
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 7th Jan 2009 22:35
Ugh...the sphere is a different color each time...this makes no sense at all.
OceanJeff
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: Ocean Shores, WA
Posted: 8th Jan 2009 11:08
Ok, the reason you are falling through the floor with this collision check is because you need to check if you are already on the other side of the floor before you update your player's location.

Check if new location is acceptable, if not, then don't update position. If it is ok, then update position.

Also, you can branch and do other things, if your new position is fallen through the floor, such as set it to hit the floor, or bounce, etc.

Hope this helps, I'm sort of a beginner, and sort of a veteran...lol

later, and have fun, would love to see your completed work...I am still finding my way around this forum, and web site.

jeff

puppyofkosh
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 8th Jan 2009 22:15
Thanks a lot, I'll try it!
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 9th Jan 2009 01:17
Bounce:
float bouncefactor=0.5f;
velocity = velocity *= -bouncefactor;
puppyofkosh
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 12th Jan 2009 22:42
Sorry for the bump, but thanks! It works fine with some tweaking (The player would kind of go up, only to be pushed down again whenever he looked up and pressed the forward key) so now it works fine, thanks again for all the help, and I'm sure I'll have some more questions soon.

Login to post a reply

Server time is: 2024-11-25 11:36:18
Your offset time is: 2024-11-25 11:36:18