RigidBody/Collider physics, or simple script?

I'm making a game that, gameplay wise, is completely 2D. A plane with 3D models on it. It's set in space with inertial physics.

My physics needs are pretty simple Newtonian stuff. An object with some mass value is applied a force of `(x,y)`. And all objects are considered circular, so if 2 objects are within a distance of `a.radius + b.radius`, then a collision occurs, forces are applied to both objects and some logic is triggered.

So my question is wether it's worth using `RigidBody` or the various collider components or to roll my own scripted solution for these physics. It seems like `RigidBody` is overkill. I don't need gravity, or center of mass, or friction or 3D polygon collision detection. I just need proximity based collision detection and 2D billiard ball style newtonian physics.

And I am betting that Unity physics and colliders would make this easy, but I would pay extra for them in performance due to all the features I'm not actually using on these components that it is processing anyway.

The built-in physics are better-optimized than what you can do in scripting. Just moving an object in a straight line is 30% faster with a rigidbody and AddForce vs. using Translate() in FixedUpdate, and that's obviously without any collision detection code or anything else. Adding collision and other features makes the physics engine increasingly faster by comparison.

Most physics features that you're not using aren't applied anyway...friction only matters if two colliders are in constant contact, so that would never be calculated in the first place. 3D polygon collision detection only applies if you're using a mesh collider, which you wouldn't be doing anyway, you'd be using sphere colliders. There's no reason not to use the built-in physics, unless you need specific behavior that those physics can't provide.

This developer has done some comparisons of Box2D running in Cocos2D and PhysX running in Unity and found that for the same 2D test scene Box2D is roughly twice as fast as PhysX.

http://flyclops.com/battle-of-the-ios-physics-engines-197#comment-114

I've often wondered about this comparison too. I've seen a lot of 2d physics games which use the 3d engine constrained to 2 dimensions, but I've never seen any performance comparisons which weigh that up against using a scripted 2d-only physics engine.

I would say if your game is genuinely only 2d circle-circle collisions & responses, a roll-your-own approach could possibly perform better. This is a guess though, and would largely depend on how you implemented your 'early-out' techniques for limiting the number of distance tests (eg, by using a large 2d grid of 'bins').

If you were to also require other arbitrary 2d shapes for collision, I'd be much less confident, but like I said, I've never seen the two methods compared for performance side-by-side. I'd be very interested to see your results.

Well, performance isn't a huge issue, unless you're planning on having lots of gameObjects. So, yes, it's worth having colliders. Rigidbodies are also good, and turning off settings doesn't really effect performance, as I said before, unless you're working with large amounts of objects.

In fact, you can disable all the settings and work with `rigidbody.AddForce` to simulate gravity, and add forces on collision, which you can figure out using collision info and the connected rigidbody.

Also, scripting your own physics isn't worth the time when you have the Ageia PhysX physics engine at your fingertips.

This developer has done some comparisons of Box2D running in Cocos2D and PhysX running in Unity and found that for the same 2D test scene Box2D is roughly twice as fast as PhysX.

http://flyclops.com/battle-of-the-ios-physics-engines-197#comment-114