0 Favourites

How do I use BBox as a collision alternative?

  • I'm already using a collision polygon but would also like to use the common expression BBoxLeft, BBoxRight, BBoxTop, BBoxBottom for some custom collision detection using the BBox of a Sprite.

    What I'm trying to do is making a check if any sprite BBox in SpritegroupGroup1, overlaps any Sprite BBox in SpriteGroup2.

    Would something like this work to return true? and how would i go about making it true for every instance of the object?

    Sprite1.BBoxLeft > Sprite2.BBoxRight

    Any idea how i would go about to create some events for this custom collisions using BBox of a sprite?

    Any help Appreciated.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Hmmm. In order for it to detect a collision or overlap i guess i would need 2 At least 2 BBox values intersecting with 2 BBox values of another Sprite.

    Condition1 - Sprite1.BBoxLeft & Sprite1.BBoxTop (X and Y of Top left corner of the first sprite) < Sprite2.BBoxRight & Sprite1.BBoxBottom (Lower right corner of Sprite2) if true, that would indicate that the two Sprites BBoxes are intersecting on at least one corner?

    Maybe it would be good to add a X & Y instance variable for each corner of a Sprite BBox. I guess i would get values like this for a 100pixel square box.

    BoxCornerTopleftX =100

    BoxCornerTopleftY =100

    BoxCornerToprightX =200

    BoxCornerToprightY =100

    BoxCornerBottomleftX =100

    BoxCornerBottomleftY =200

    BoxCornerBottomrightX =200

    BoxCornerBottomrightY =200

    Then it would be pretty easy to check if there is any intersections with any other sprite.

    Continuing my experimentations, think I'm getting there.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)