Collision shape for 2D Space game

This topic is 2121 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi!

What kind of shape should I use in a 2D topdown space game for collision? I was thinking about AABB, but as the ships are rotating they are not the best option. I was thinking about OBBs or a group of Bounding Circles. I'm more into the circles because of the performance, and I can define a ship's collider more precisely with more circles. I would like to hear your opinion too

Share on other sites

I'd go with circles. Probably more fun gameplay if you don't have to worry about your orientation affecting whether something hits you.

Share on other sites
What we did was precalculate bounding boxes and collision corners for all objects. Then when two objects were close enough to potentially collide we projected the collision corners to world space and then to the other potential colliders space and checked wheter it was inside a bounding box. since the boxes were always axis aligned inside the objects personal space it was extremely efficient way with pixel perfect collision. Granted you need to check both objects corners against the others bounding boxes to be sure they weren't colliding so it is slower than with circles. But even in this approach you are most of the time comparing circles to see if they are close enough to be colliding in the first place so it's not that much slower.

As an added side bonus this method gave us the collision point that we later needed to do our rigid body collision math.

The correct choise really boils down to the question. Do you need pixel perfect collision? if not the go with just circles as they are relativily easy to implement and are quite fast.

Share on other sites

I used rectangles on my bat monster in space. Had it on both wings and the tail. Collision works really well.

Edited by warnexus

Share on other sites

Best would be to have multipolygonal object shape for nearphase collision checks and aabb or sphere for boradphase collision checks.

aabb check is faster a little bit than sphere, sphere usualy takes less area, but which method to use depends on game and benchmarking.

Other aspect is finding aabb or shere for moving and rotating object. With multipoligonal shape you will need to loop all shape points and find aabb or use Ritter

algorithm to find minimal sphere or use shape precalculated center point and precalculated sphere radius.

If you dont have multipolygonal shapes than use aabb or sphere , one that is more closer to objects sprites shapes.

Edited by serumas

• 9
• 17
• 10
• 11
• 18