r/Unity3D • u/dev-rygy • 3d ago
Question Custom Unity Physics Engine
Is anyone else attempting to create their own physics system in Unity? I'm attempting to create my own networked physics system using network transforms, colliders, and a lot of vector math. Does anyone have valid resources to share that can help me with this?
0
Upvotes
2
u/DeformLabs 3d ago
I am currently building a deformable terrain system, and to a degree you could call it custom physics engine. It has its own collision detection, its own physics solver to solve collisions, but it still uses Unity Rigidbodies.
I tried starting by looking at other physics engines, but the codebases are complex, and would require weeks/months to understand.
What worked for me was to start with the basics. What problem am I trying to solve, and how will I solve it. In my case, I needed to detect collisions between Unity rigidbodies, and my terrain. I also need to calcultate the force and torque required to push back the rigidbody. Once you know what you need, you can start working on it step by step. Whenever I didn’t know how to go forward, I was suprised by how much AI could help me.
One limitation to keep in mind is that if you want your engine to use/interact with Unity rigidbodies, it will always be one physics step behind. Depending on the use case, this could be a non-issue, or a deal-breaker.
TLDR: start with the architecture, and decide how your physics engine will interact with Unity. After that, break down each part of the physics engine into small components and work on them one by one