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.

Newcomers DBPro Corner / how to create collision boxes

Author
Message
Chaotic BroOfThe1
12
Years of Service
User Offline
Joined: 21st Nov 2011
Location: wherever i wanna be
Posted: 12th Apr 2012 05:34
can someone show me a basic code for creating collision items?

There is no right or wrong- there is only belief.
nonZero
12
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 12th Apr 2012 09:29 Edited at: 12th Apr 2012 14:18
Could you specify 2D or 3D. The priciple's sorta the same: automatically, basic boxes exist for both (2D being the 4 corners of the image). The easiest way (and it uses no real resources) is to create an invisible object. On my mobile right now so can't type code but you just MAKE OBJECT BOX dummy, xsize, ysize, zsize and then update its position to that of your target object (that you are making the box for). In 2D you can just CLONE SPRITE your target object, SIZE SPRITE your clone and then HIDE SPRITE your clone. As with 3D, just add a line to reposition your hidden dummy. Beware: with 2D coords aren't centered, they're from the top left corner so you will have to calculate the size difference for repositioning. This should be enough. Will be back later and post code once you specify if it is 2D or 3D you are after (if needed).

EDIT: I shall dump some examples here, watch this space:

2D Example 1: A basic box (Seldom necessary as DBPro's built in collision is fine for square sprites)


Example 2: Some basic 3D collision


Chaotic BroOfThe1
12
Years of Service
User Offline
Joined: 21st Nov 2011
Location: wherever i wanna be
Posted: 13th Apr 2012 03:22
thank you- I will play around with the code for a bit- try and get a better understanding of it on my own. I am trying to do 3d collisions but i will try to learn both. thank you very much

There is no right or wrong- there is only belief.
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 14th Apr 2012 01:09
There is also a MAKE OBJECT COLLISION BOX command which will make a collision box for a specific object. You can also use the SHOW OBJECT BOUNDS command to view a wireframe version of the collision box for a 3D object.

Login to post a reply

Server time is: 2024-05-18 02:56:19
Your offset time is: 2024-05-18 02:56:19