Custom physics engine integration with Unity3D

Hello!

I'm currently implementing my own physics engine in C#, which is fully oriented to cars trying to provide them with a realistic behavior, as I'm looking forward to create a racing game.

I would like to know how can I include my personal physics engine to work with the engine and provide cars with the proper physics engine. Has anyone tried something similar when trying to include a different physics engine into Unity?

Hope you can help me out a bit with this!

The integration into Unity should be relatively simply. I personally would have some kind of PhysicsManager class, that inherits from MonoBehaviour and has a very low script execution order, such that it is executed very early:
http://docs.unity3d.com/Manual/class-ScriptExecution.html

The PhysicsManager could then perform the physics updates in the Update method. In there you need to trigger all the physics events to the relevant game objects.
Then you need to create your custom rididbody and collider classes that inherit from MonoBehaviour, such that they can be added as components to game object and be configured like that. They need to have their own OnCollisionEnter/... variants, that are triggered by your PhysicsManager, just like your custom FixedUpdate.

With all that, you should get an integration just like the currently existing one for PhysX, but for your custom physics engine.

1 Like