For my first game i want to create a topview game in c++ where you can drive a car (like in gta2). As far as i know i dont need any gravity. While doing a bit of research about games they often advice a physics engine. What are the benefits of a physics engine on a topview game?

  • \$\begingroup\$ that you have not to write your own FE ? \$\endgroup\$ – dnk drone.vs.drones Sep 14 '15 at 12:22
  • \$\begingroup\$ Well, you get physics, without having to write all your own physics code. That's really all there is to it, at a high level... \$\endgroup\$ – user253751 Sep 14 '15 at 14:05

Using ready-made components which are widely tested and professionally optimized instead of rolling your own can save you hundreds of man-hours of developing, testing and bugfixing...

...if they solve the problems you would otherwise have to solve yourself.

What any 2d physics engine should provide and what you definitely will have use for is collision detection. Finding out if and where two shapes collide is a problem almost every game needs to solve and which is easy to get wrong or unnecessarily slow when developed from scratch. So why reinvent the wheel when you can use collision detection algorithms already developed by someone else?

What might or might not be useful for you is managing movement. Acceleration and friction are usually not hard to do yourself, but what might be more challenging for you is calculating velocity vectors after impacts (how two cars push each other when they collide). Delegating this to a physics engine will give you a solid implementation with minimal work. Just make sure that the physics engine allows bodies to have different frictions for movement in different directions relative to their current rotation. This is necessary to account for the fact that cars are easier to push forward and backward than sideways. Otherwise your cars will behave like hovercrafts.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.