Jump to content
  • Advertisement
Sign in to follow this  
robee00

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!