Collisions and Bounding Boxes
Hey folks! While I was debugging my new game, I found myself requiring to see the bounding boxes of my game objects, and also to better manage the collisions and intersections between them. I have made a toy plugin that does two things: 1. Draws a BBox around your object. `collisions.draw(object, {tint: 0x00FF00}}` 2. Triggers a behaviour / function if two object collide: `collisions.start(object1, object2, {onCollision: function () ... {})` Here is a small video showing both functionalities. I remember our conversations about making it easier to debug as well, which `draw()` does. https://www.loom.com/share/1660d3dda9b64d50a826fe8bae9a6805 Do you find it useful? Would this help debug your games? Would this help you have a better code but delegating the behaviours on collisions to the collisions plugin? I hear you π
20
I love the idea of a collision plugin. Seeing the outline of where the boundaries of the collision box actually is would be super helpful.Β
But more helpful than any of that would be the ability to assign different shapes to the collision plugin. Even if we just had access to circle, square and triangle by default it would be so much better. Rectangle and oval also helpful, but we could just make these shapes by settings dimensions.Β
In my opinion, itβs a big issue for the quality of games and I always end up using circles instead of the default because nothing feels more unfair to players then getting a collision when itβs clear that neither of the assets touched visually.
Optimally we should have shape to shape intersections. E.g. the graphical asset should determine if there is intersection or not based on the alpha mask.
Usually sprite-perfect bboxes are super heavy computationally speaking. They are supported in many game engines but not very used as the game scales in resources consumption. But we can experiment a little with all the options we have and check impact!
Personally, I find the different shapes making a huge difference. Iβd be happy even with that.