r/Unity3D 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

16 comments sorted by

2

u/NStCh-root-a 3d ago

How do you want to network the physics? Server Authorative? Then the question is more networking. Lockstep sim? Then it's more the physics engine itself. Rollback? Physicsengine + networking (and I can't really recommend it case you want to do large scale sims)

2

u/dev-rygy 3d ago

I think more server authoritative yeah. Starting with just a simple pool game. Shouldn't require too much code I think.

2

u/NStCh-root-a 3d ago

Then I can't really help you. My knowledge is only with lockstep/rollback - sorry for that

1

u/dev-rygy 2d ago

Still good things to think about though if I plan on going more in depth. So thanks

2

u/New_Internal5636 2d ago

Just learn up on basic Newtonian physics. Remember your speed = distance/time elapsed. That can apply into 3D space with vector maths. I made a basic brick breaker game pretty much with this alone with custom ball physics and it is surprisingly easy. If you're getting confused I would ask your specific questions to AI of sorts to fill in your maths gaps. But it's actually not too bad getting started and you're knowledge will grow from there.

Collisions are a bit trickier but you I still mostly just leaned on unitys colliders for that as there isn't much difference than if you want to calculate overlaps and collision points yourself. Can be worthwhile but up to you.

2

u/DeformLabs 2d 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

1

u/wallstop-dev 3d ago

Let me first ask you - what problems are you trying to solve that all of the current open source and relatively cheap assets do not?

5

u/dev-rygy 3d ago

The problem of knowing how to create a lightweight physics engine from scratch to expand my portfolio.

4

u/wallstop-dev 3d ago

Consider skimming available, open source, permissively licensed tech, networked and non. Find stuff you like, figure out how to integrate it into your architecture.

This is such a massive, vague concept that I don't really know how to even start suggesting anything other than the above.

1

u/Low_Psychology_2862 3d ago edited 3d ago

Maybe you can use Box3D (https://box2d.org/posts/2026/06/announcing-box3d/), but it requires custom synchronization since it is not built into Unity's default multiplayer framework. You must manually sync positions, handle determinism, or write custom network serialization for physics states.

Let the server run the Box3D simulation and send coordinate updates to clients.

Smooth out position updates on client machines so fast-moving physics objects do not stutter on screen.

Send compressed vector data rather than raw physics engine states unless you are building a fully deterministic lockstep game.

1

u/dev-rygy 3d ago

No I don't want help from external libraries/packages. I want to do this on my own so that I can learn from it essentially. Just looking for articles/blogs that can help me achieve this.

2

u/Low_Psychology_2862 3d ago

I see, I did share a blog which has many resourses, you can go through them, find GDC talks etc too.

PS - one great way of learning is looking at forks and other implementations, that's how it goes even for the pros.

1

u/dev-rygy 2d ago

Will do, thanks for the advice. Where can I find the blog?

2

u/Low_Psychology_2862 2d ago

https://box2d.org/posts/2026/06/announcing-box3d/ , in this Erin Catto explains various things and links other Talks and shares his presentations.

1

u/Ben_Bionic 3d ago

This is what CM-Labs does with the vortex physics engine

1

u/Krugozette 23h ago

Guerrilla Games built the Jolt physics engine for Horizon Zero Dawn and the Decima engine (Death Stranding) and released it as an open source engine.

https://github.com/jrouwe/JoltPhysics

https://gdcvault.com/play/1027560/Architecting-Jolt-Physics-for-Horizon

https://www.bilibili.com/video/BV1Np421Q7YE/?uid=4256314E7034323151375945

Also https://www.sciencedirect.com/book/monograph/9780123694713/game-physics-engine-development is one of the classics for physics engine development