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 / object collision, on an incline.

Author
Message
mit45
15
Years of Service
User Offline
Joined: 28th Apr 2011
Location:
Posted: 28th Apr 2011 16:50
I'm fine with object collision box's, on rectangular prism objects. (this is in 3d) I was just wondering how i could get the collision detection to work if i rotate said object on the x axis. becausr right now i just go through the floor, because the object collision box is flat.
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 29th Apr 2011 01:43
I would think of looking at the Sparky's collision. Using a command like SphereCast collision (using a radius from the point of origin) you give it the start XYZ and where your moving to XYZ and you can then retrieve the sliding values against anything that has been collided with. This can be handy for adding gravity also because you can constantly move around but check the falling too.

http://forum.thegamecreators.com/?m=forum_view&t=183982&b=1
Above is an editor I've done which uses sparky's collision but within the DBP demo examples you will find the sliding collision and how it works. Quite easy once you understand it.

The editor is almost in an update mode with a few more examples. Anything else you need to know about Sparky's then there's plenty about that should be able to help.

Warning! May contain Nuts!
Daniel wright 2311
User Banned
Posted: 29th Apr 2011 01:50 Edited at: 29th Apr 2011 01:54
Or you can also use a disstance fourmula to stop it, like if object distance is x then stop object 1.this is a faster way to do it.

edit, or with this function put it like this

check =CheckObjectCollisionArea(your box, the floor, 5)

if check =1 then stop object




my signature keeps being erased by a mod So this is my new signature.
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 29th Apr 2011 02:29 Edited at: 29th Apr 2011 02:31
That's not accounting for rotation of an objects collision. Although the sphere cast in sparkys (which should be standard with DBP) doesn't account for the origin rotation (and there's lots of collision type setups too), it does give a return of sliding values depending on the 'speed' of the collision.

It is pretty much the same as:



EDIT: Sliding collision isn't that hard when doing it this way.

Warning! May contain Nuts!
mit45
15
Years of Service
User Offline
Joined: 28th Apr 2011
Location:
Posted: 29th Apr 2011 15:56
In that code snippet, whats the condition on the if statement? it just says "if collision" then its a new line"
Daniel wright 2311
User Banned
Posted: 29th Apr 2011 19:31
if collision=1
newx=slidex
newy=slidey
newz=slidez
endif

he just forgot to put in the =1 wich you dont realy need here.

my signature keeps being erased by a mod So this is my new signature.

Login to post a reply

Server time is: 2026-07-11 10:44:32
Your offset time is: 2026-07-11 10:44:32