TiledMap / LibGDX - What is BEST for collision?

Hello all!

I have been programming a small rpg test game. Right now I am using Box2D for collision. All is going well and I collide with walls on my maps object layer, as many many tutorials and books point out. I have the following questions below…

Is Box2D overkill for collision?
Is the “com.badlogic.gdx.math.Rectangle” better?
What is the best collision detection for multiple devices and operating systems?

Working with Box2D has been a lot of fun. But my concerns are on performance. There isn’t much up to date information on google. I am hesitant to use opinions that are more than a few years old, for understandable reasons. Sorry if this seems trivial, I just want to “code it the right way.” :slight_smile:

Also, if you have any other recommendations or considerations that I should know for the future, please post them!

Thank you!

Unless you working with anything that relies heavily on physics, I would stick with rectangles and circles. Not for performance. But for simplicity and super-accurate collision detection does not matter 99% of the time.

The only advice I can give you is not spent much time of collision detection. 1 hour or 2 tops. It hardly matters and its not very fun to work with. Also, there is no such thing as coding the right way. As long as your solution is simple and works and is sometimes flexible, its good.

I’ve been told that you can use box2d JUST for collision detection, but, especially if it’s a ‘top down’ game, box2d will likely be overkill.

I personally preferred using libgdx built in sat algorithm, but that’s only because I wanted to have terrain made of polygons, not boxes.

Box2d is quite efficient, and you can write tests to see just how much your computer / ipad / phone can handle, you might be surprised.

However, it really sounds like it is ALOT more than you will need for collisions in an rpg game.

Thanks so much for the comments guys! I will stick with box2D as I would like to incorporate Box2D lighting :slight_smile: