Hello! I’m a C++ programmer used to graphics and OpenGL stuff. I’ve started learning Unreal very recently. Now I’m studying cloth simulation on the engine.
There are some good tutorials explaining how to do cloth simulation using the editor such as:
We also have the documentation of clothing tool:
However, I haven’t found anything on how to setup/run such simulations programmatically in C++.
Let’s say I have an application where I allow the user to draw some closed 2D polygons. I want to triangulate these polygons to generate meshes and then simulate these meshes using Unreal’s clothing system.
I guess that creating fancy garments might be a lot of code, but a small code showing how to create a waving flag, for example, would help me a lot.
That helps me because every blueprint tutorial kinda works as a C++ tutorial too.
However, I’m still missing more documentation/tutorials on Unreal’s cloth system.
For example, with this vídeo I learned that making cloth collide and interact with world objects or the environment is tricky, but it’s not clear to me the reason. Is the approach used in the video the only way to work around this limitation?
Yes, unfortunately there is no detailed documentation about cloth simulation. I think it’s because UE4 use PhysX for cloth simulation whitch is an nvidia framework. You can find some more c++ documentation if you search externally like here: Cloth — NVIDIA PhysX SDK 3.4.0 Documentation .
UE5 will run cloth simulation on the Chaos System so maybe the workflow will totally change in the future for clothing and physics in general.
Other useful things you should know:
Cloth simulation is currently based on PhysX Cloth but you can create APEX assets both directly with unreal or using the nvidia tool and importing the APEX file (PhysX Clothing | NVIDIA Developer)
You’ll need to use a separate material from the base character to avoid issues
There are some limitations concerning dynamic shadows per material/mesh section