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 Professional Discussion / How to stop player from going down?

Author
Message
B++
16
Years of Service
User Offline
Joined: 6th Dec 2009
Location: India
Posted: 2nd Dec 2010 09:16
I am making a 3D platform game (Like Mario). Got a little problem.


It the code for the gravity. with sc_objectcollision it stops falling when it collide the ground. Is this good idea to use sc_objectcollision or I should use some other command? Any idea about platform collision!

Thanks in advance
Regards


Your Signature Here;
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 2nd Dec 2010 09:58
One thing that concerns me is what you do with your Y coordinate on a collision - because it doesn't appear to reset to the previous or adjust. Perhaps it would be an idea to do a line intersection check from the players head to well below his feet - then use that to guage the ground height. When you know the exact ground height, you can adjust the player Y coordinate to suit. Maybe increase gravity if there is no collision, if there is a collision then check the Y coordinate with the ground height and adjust as needed. That way you could check the slope where the player is trying to run to, if it's too steep then stop them, or even adjust the X speed according to the slope, ala Sonic the Hedgehog.

There is also sphere collision, which might work out nicely for platformer collision - you should check the demo supplied with sparky's.

Health, Ammo, and bacon and eggs!
B++
16
Years of Service
User Offline
Joined: 6th Dec 2009
Location: India
Posted: 2nd Dec 2010 10:38
Actually, when intersecting, if the oldy value is oldy# than which would be the new y value? It is making me confuse!!

I will check the demos.

Thanks for the reply.
Regards


Your Signature Here;
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 3rd Dec 2010 09:30
Line intersection is usually used in things like bullet collision - you specify 2 sets of coordinates. So if it was a bullet, you would work out the new position based on it's velocity, and check for collision between the current and new position. Because it's a character, it might be best to use the head, by working out the position or height of the head, then doing an intersect check from the head to below the feet.

Health, Ammo, and bacon and eggs!
B++
16
Years of Service
User Offline
Joined: 6th Dec 2009
Location: India
Posted: 3rd Dec 2010 10:23
Thank you Van B for ur reply. I made it(almost working) yesterday night. Just having trouble when it jumps. it does not collide with walls when it jumps else it is working.

I will try to fix it.

Thanks
Regards


Your Signature Here;
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 3rd Dec 2010 12:48
Along with the vertical line intersect check, you could do a horizontal one too, like across your characters waist. That's how we would do it in earlier versions of Sparky's - but as I said, I think you should look at sphere collision as well, because it accounts for the sides. As it's a totally 3D game, really you should try solid collision (sphere to polygon), as it might just make all the difference, and provide a nice, robust collision system.

Health, Ammo, and bacon and eggs!
B++
16
Years of Service
User Offline
Joined: 6th Dec 2009
Location: India
Posted: 3rd Dec 2010 14:06
Quote: "but as I said, I think you should look at sphere collision as well, because it accounts for the sides."

do you mean SC_SphereSlideGroup. I am using this. Just having a little problem right now. After jumping if I keep pressing the WASD key, it stuck with wall until I release the key. Perhaps it thinks it has touched the ground. Trying to solve this.

Regards.


Your Signature Here;
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Dec 2010 19:37
In your first snippet you have:



Should that be:



?

I assume you want the size of the change in Y to change over time (as in real gravity). Unless ny is changed somewhere else in your code ny# (a different variable) won't change.

Or was it just a typo in your post?
B++
16
Years of Service
User Offline
Joined: 6th Dec 2009
Location: India
Posted: 4th Dec 2010 11:17
Ya, I mistyped it. Sorry. it is


Thanks
Regards


Your Signature Here;

Login to post a reply

Server time is: 2026-07-21 10:41:57
Your offset time is: 2026-07-21 10:41:57