0
\$\begingroup\$

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?

\$\endgroup\$
2
  • \$\begingroup\$ that you have not to write your own FE ? \$\endgroup\$ Sep 14, 2015 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, 2015 at 14:05

1 Answer 1

2
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .