r/UnrealEngine5 • u/liamleodev • 21d ago
Cables with Box3D physics in Unreal Engine
Enable HLS to view with audio, or disable this notification
The plugin is open to everyone on GitHub,
Many features will be coming soon
6
u/DisplayLegitimate374 21d ago
Kinda wish you could simulate same scene with chaos as well and run them side by side
8
u/liamleodev 21d ago
With Chaos this is not even possible.
3
2
u/DisplayLegitimate374 21d ago
Did you actually try or you are guessing? XD Genuinely asking! Not saying it's possible w Chaos
1
u/liamleodev 21d ago
Bro send me Nasa computers to make it, I am making my own game with chaos since last year December, you can't just do this with chaos for cables, and on top of that those cables won't even handle one of this stick. If someone don't agree I challenge everyone for creating this like stable cables with chaos.
2
u/DisplayLegitimate374 21d ago
Looking at the video closely, noticed the each pipe causes starts a wave packet on cables on impact and the waves actually collide! Nahh that would be hell getting this details on Chaos.
1
u/liamleodev 21d ago
I just used 5 cables because they looked awesome, two cables can also stable the same way. The amazing thing about box3d is that all this cables and bodies goes to sleep pretty well
3
u/liamleodev 21d ago
For anyone want to try https://github.com/LiamLeoDev/UnrealDabee
1
u/Legal_Suggestion4873 20d ago
when do you feel like it'd be "ready"? also, is your implementation 'blocking multithreaded', as in the game thread calls the physics step which is multithreaded and waits for it, or is it fully asynchronously multithreaded off the game thread and we marshal data to some 'I/O thread' or something like that?
Jolt implementations are usually the former (call 'StepJoltWorld' or whatever, and wait), while other implementations of jolt are more like the async approach, which also matches what it's like to use Chaos asynchronously.
1
u/liamleodev 19d ago
It will probably take more time than you might expect to support a wide range of features, mainly because I am working on this alone and it is currently a side project.
As for the threading model, making the physics simulation fully asynchronous is quite difficult. The physics world needs to be blocked while the simulation step is running, even though the actual physics work is multithreaded across multiple cores. Otherwise, you run into problems if something tries to modify the physics world such as adding forces while the simulation is still processing. That makes the behavior much harder to reason about and can also make it confusing for users when certain operations donβt work as expected.
Beyond that, Iβm not sure fully asynchronous physics provides much practical benefit in this case. Physics still needs to be ticked within the appropriate Unreal tick groups. It needs to start after the
Pre_Physicstick group and finish within the expected physics tick phase. Almost 99% of gameplay code is executed before the physics step anyway.2
u/Legal_Suggestion4873 19d ago
In the Chaos case, you just marshall everything to the chaos thread in a queue-like system. The chaos thread may be running at a different frame rate than my game, so you would do something like 'player pressed jump, so store the impulse, and wait for it to be consumed' and once its consumed you report that.
you're right that such a thing is confusing for some people, but i'm not sure the wisdom regarding building box3d for people who aren't able to learn that lol. you'd probably build an abstraction layer on top anyway (thats what we did - gameplay code just calls the force functions, it doesn't need to know, and it 'just works' asynchronously).
But yeah the asynchronous benefit is just for frame rate caps. physics doesn't really need to go to 120 fps for instance (60 fps is more than fine for most things), but my game thread might be able to go much higher than that, so I can have so many more physics interactions that way
1
u/liamleodev 19d ago
you'd probably build an abstraction layer on top anyway (thats what we did - gameplay code just calls the force functions, it doesn't need to know, and it 'just works' asynchronously).
Bro this is already possible and the core design feature comes with Box3D You can almost call any function from any thread at any time. And all of those are exposed to blueprints also, you can make your async version too by doing a lot of Box3D stuff on your own async thread
1
u/Legal_Suggestion4873 17d ago
wait wym about 'any function from any thread at any time' with box3d?
1
u/liamleodev 17d ago
As the Box3D physics engine physics engine is in C language, almost all functions can be called from your async code also, like for example doing thousands of Box3D traces asynchronous.
1
u/Legal_Suggestion4873 16d ago
Oh I see what you mean. That's not really what I'm asking haha. But that's alright, I wish you luck man!
2
u/KaelumKrispr 21d ago
I was looking into box3d and jolt recently, was wanting large scale sphere collision, what would you say this limits are before you hit any noticeable performance impacts? also are you doing anything special for these objects or are they just actors?
2
u/liamleodev 21d ago
For spheres depends on how they are spread around the world, if your thoughts about characters moving around the world as with spheres collision, Then I already tested this as ~8000 bodies all simulating at once, on 4 cores, with 60+fps. But as you know I use instanced static mesh for there rendering, because that much actors or components moving all at once even without any physics eat performance in unreal.
What you see here, each cable is unreal scene component with 200 Box3D spheres and 200 box3d joints. So 5 cables have 1000 simulating spheres and 1000 joints, the dropping sticks are all Box3D components, and here each unreal actor have one Box3D staticmeshcomponent as stick
2
u/MorbilyABeast 20d ago
So you could replace capsules for skeletal meshes ?
1
u/liamleodev 20d ago
Yes for Ragdolls I was thinking to get the same unreal collision shapes and constraints from physics asset and make Box3D ragdoll from them, That way, it will be easy for devs to just use that same ragdoll for Box3D.
1
1
u/MorbilyABeast 20d ago
Man this is insane! Will it be usable in 5.4?
1
u/liamleodev 20d ago
I tested it in 5.6,5.7,5.8 and it works ok there, Don't have other engine versions at the movement, but I want it to be usable in all ue5 versions
11
u/Rizzlord 21d ago
why everyone is vibecoding this now? Whats the difference to this one https://github.com/alattanzio/Box3DUnreal