Is it possible to create a faster physics engine than what roblox is currently using

I want to achieve really fast and accurate physics, like in this video.

This guy created a physics engine which can handle absolutely insane amounts of physics objects from just his cpu. I want to recreate this inside of roblox, but I’m not exactly sure where to start.

Chickynoid seems to have a really good custom physics engine, but it’s not quite what I’m looking for.

1 Like

DISCLAIMER: I’m not the most educated person when it comes to topics like this but I’ll give it a go.

From what I have read, Roblox uses a variable number of CPU cores to process physics, both on the client, and the server. Afaik, Roblox’s physics engine was written in C++. Generally speaking, this means it’s going to be faster than Luau because while Luau is pretty fast, the physics engine was specifically optimized in ways that aren’t possible in Luau.

Now from what I understand, Roblox’s physics engine could definitely use an upgrade but it’s not completely terrible.

Based on the video’s description, they’re using a new CPU with a lot of cores. That’s going to be the biggest factor in determining the amount of performance you will be able to achieve. You also have to be aware that we don’t know what the saturation of all those CPU cores are during his demos. If it’s at like 80-90% usage, that doesn’t leave much room for other aspects of a game.

In any case, if you want to make your own physics engine in Luau, you will need to learn how to use multithreading. You would need to learn how to split up the load across multiple cores, evenly. ie, if you have 100 parts to calculate in a single frame, and 8 cpu cores, you want to give each core ~12 parts to calculate. However that’s a very basic way of looking at it, and in reality it will be more complicated. Not everything parallelizes well It’s a fairly new feature and doesn’t work perfectly but it let’s you run Luau code on multiple CPU cores. The main caveat with this though is that there are issues with accessing and modifying properties of parts in parallel. Meaning, you may have to use some hacky solutions like using multiple scripts with multiple parts parented under different “actors” (read the article i linked) since you can’t read/write the position of parts while running code across multiple cores.

You would also want to learn how physic grids work, basically some kind of “chunk” system. You can adjust how frequently/accurate the computations done for certain parts are by checking how close they are to other parts.

There are people who have made videos about this on youtube who can explain this much better than I can.

It’s possible that you could create a physics system that is more accurate, or faster than Roblox’s, but I doubt it’s possible to have both at the same time.

PS: You may look into changing workspace.PhysicsStepping to adaptive as it dynamically adjusts accuracy to increase physics frame rates.

4 Likes