Tutorial: Cloth Collision with World

In the past, colliding cloth simulation with world objects has been difficult to accomplish. We’ve tried to amend that issue in Chaos cloth for UE 5.0 by making cloth simulation and world mesh collisions easier to create.

https://dev.epicgames.com/community/learning/tutorials/p4a1/unreal-engine-cloth-collision-with-world

4 Likes

This is a perfect tutorial, although i have a few questions.

  1. Can I do this with UE4 (previous version) or this is only available in UE5?
  2. I don’t know how to make the cloth hang on the hanger and not collide with the hanger while it moves, do I import this as a joint mesh from Blender and add custom collision to the hanger?

PRE - chaos, using PhysX this could only be done by SkeletalMesh collision.
Your cloth item would need to have bones and colliders assigned, with a very light value assigned to cloth simulation so that it would respect the skeletal mesh deformation.

Post chaos, in 4.27 (custom chaos build), the chaos cloth world collision never worked right (engine crashes) up to 6 months ago.
While I hope that it was patched and works, my experience with unreal is: don’t hold your breath.

Regarding the hanger question. The shirt and the hanger are probably a single item. the cloth value on the hanger is probably derived from vertex paint.
Probably still use my plug in for it:

Yes, this is only available in UE5 (Chaos). The hanger is basically a simple physics asset with two tapered capsules for collisions. That, coupled with Max distance painting and falloff seemed to work for this example. It’s quick and rough, but does the job.

Thanks a lot, I’ll see if i need UE5 as your hanged cloth in the tutorial looks super cool.
I just ended up doing some work around, created a mesh in Blender while the shirt was falling as one arm was held by a collision object (cylinder) and inverted that falling shirt into a mesh and in a new blender file joined it with a hanger and now the shirt is only half hung on the hanger (as i desired), now using the wind and gravity in UE4, looks fine.

But still as you can see material looks unsmoothed, is it possible to access your cloth material and texture from the tutorial?

I’ve been following this and several other tutorials when trying to create a sort of curtain that flows in the wind. I think there’s a known issue with wind not affecting some cloth stuff but the big problem I have at the moment is that my curtains have no idea how to collide with the environment. I can’t seem to find out how to tell my cloth how to collide with the environment.

World Collision is a Chaos Cloth 5.0 update. This is not a feature of 4.27 NvCloth, just FYI. If you are still having issues with collisions, make sure your Chaos Cloth iterations are set high enough. Experiment with subdivision settings, too. Increasing both will have a hit to perf, but if I’m ever having issues with any collisions I will bump those settings up first.

Since I’m not aware of your particular cloth setup, are you trying to move objects through your curtains or have curtains collide with a wall, etc? If it’s a wall, I’d use PhysicsAsset collisions as part of the curtain skeletalMesh. If it’s objects moving through the curtains, I’d first try the iterations/subdivisions increase I mentioned above.

1 Like

I did fix the issue with the cloth not being affected by wind. If I had to guess, my skeletal mesh is missing something that it needs in order to tell it to collide with the world.

Here’s a brief demo of the issue: UE5 Cloth Collision Issue - YouTube

This works fine. But, I have one skeletal mesh with clothes and the clothes collides fine with its own physic body and with static objects. But as soon as I walk close enough to another skeletal mesh with the same settings, the engine crash. It doesn’t matter how many bodies the physic body has, it will crash.

To check this, grab the default third person project, add a painted cloth to it, and put two instances in the scene with collide with environment enabled, possess one of them and walk in the direction of the other.

Thank you for the reproducible steps. I’ve alerted the engineer and we’ll investigate from our end.

1 Like

Thanks. This crash happens from time to time.

It will happens every single time if one of them is an active ragdoll (with an UPhysicalAnimationComponent)

        PhysAnim->SetSkeletalMeshComponent(Mesh);

        FPhysicalAnimationData Data;
        Data.bIsLocalSimulation = false;
        Data.OrientationStrength = 500.f;
        Data.AngularVelocityStrength = 100.f;
        Data.PositionStrength = 500.f;
        Data.VelocityStrength = 100.f;
        Data.MaxLinearForce = 0.f;
        Data.MaxAngularForce = 0.f;
        PhysAnim->ApplyPhysicalAnimationSettingsBelow(RootBone, Data, false);

        Mesh->SetAllBodiesBelowSimulatePhysics(RootBone, true, false);
        Mesh->SetAllBodiesBelowPhysicsBlendWeight(RootBone, 1.0f, false, false);

        this->CapsuleComponent->SetCollisionEnabled(ECollisionEnabled::NoCollision);

To prevent the pawn from falling and keep it standing, I add a sphere to the root of the default third person physic body as kinematic and without collision. And with a free constraint to the hip. So the RootBone above is the “root” bone.

Hi, great tutorial, thanks for sharing!

Thanks I was stuck for a week on this hope the engine will fix this bug in the future

Hey @gozerKeymaster,

I’m using 5.0.3, trying to make a “flag” using this, and ticking those two options crashes the editor. In fact, I think its the “Collide with Environment” that’s the issue, I can tick that, press play, engine crash with this error message:

Assertion failed: PointFaces[PointIndex].Num() >= 3 [File:D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\SkeletalMeshComponentPhysics.cpp] [Line: 3300]

0x00007ff9f53eacfa UnrealEditor-Engine.dll!<lambda_94c16a66f41228cab5c606b59cbfab6c>::operator()() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\SkeletalMeshComponentPhysics.cpp:3300]
0x00007ff9f53e96ab UnrealEditor-Engine.dll!<lambda_5d6cc08329c3d8c27192ef069b21fd2e>::operator()() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\SkeletalMeshComponentPhysics.cpp:3411]
0x00007ff9f5083c49 UnrealEditor-Engine.dll!FPhysInterface_Chaos::ExecuteRead() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\PhysicsEngine\Experimental\PhysInterface_Chaos.cpp:682]
0x00007ff9f541b593 UnrealEditor-Engine.dll!USkeletalMeshComponent::ProcessClothCollisionWithEnvironment() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\SkeletalMeshComponentPhysics.cpp:3482]
0x00007ff9f5432420 UnrealEditor-Engine.dll!USkeletalMeshComponent::UpdateClothTransformImp() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\SkeletalMeshComponentPhysics.cpp:3634]
0x00007ff9f4180e3e UnrealEditor-Engine.dll!USkeletalMeshComponent::UpdateClothSimulationContext() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\Components\SkeletalMeshComponent.cpp:2150]
0x00007ff9f543206b UnrealEditor-Engine.dll!USkeletalMeshComponent::UpdateClothStateAndSimulate() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\SkeletalMeshComponentPhysics.cpp:3894]
0x00007ff9f543097e UnrealEditor-Engine.dll!USkeletalMeshComponent::TickClothing() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\SkeletalMeshComponentPhysics.cpp:3952]
0x00007ff9f5397cd0 UnrealEditor-Engine.dll!FActorComponentTickFunction::ExecuteTickHelper<<lambda_c41e2d2f951e9ab3b5096deedcdc912f> >() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Classes\GameFramework\Actor.h:3931]
0x00007ff9f5402fba UnrealEditor-Engine.dll!FSkeletalMeshComponentClothTickFunction::ExecuteTick() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\SkeletalMeshComponentPhysics.cpp:101]
0x00007ff9f5665a0f UnrealEditor-Engine.dll!FTickFunctionTask::DoTask() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:284]
0x00007ff9f566ccf8 UnrealEditor-Engine.dll!TGraphTask::ExecuteTask() [D:\build++UE5\Sync\Engine\Source\Runtime\Core\Public\Async\TaskGraphInterfaces.h:975]
0x00007ffa98973a9d UnrealEditor-Core.dll!FNamedTaskThread::ProcessTasksNamedThread() [D:\build++UE5\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:753]
0x00007ffa98973f3e UnrealEditor-Core.dll!FNamedTaskThread::ProcessTasksUntilQuit() [D:\build++UE5\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:642]
0x00007ffa9897d6af UnrealEditor-Core.dll!FTaskGraphCompatibilityImplementation::WaitUntilTasksComplete() [D:\build++UE5\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:2169]
0x00007ff9f5682f0a UnrealEditor-Engine.dll!FTickTaskSequencer::ReleaseTickGroup() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:565]
0x00007ff9f56898b0 UnrealEditor-Engine.dll!FTickTaskManager::RunTickGroup() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:1592]
0x00007ff9f46cf08f UnrealEditor-Engine.dll!UWorld::RunTickGroup() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\LevelTick.cpp:790]
0x00007ff9f46d79c0 UnrealEditor-Engine.dll!UWorld::Tick() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\LevelTick.cpp:1531]
0x00007ffa9398e5f5 UnrealEditor-UnrealEd.dll!UEditorEngine::Tick() [D:\build++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\EditorEngine.cpp:1777]
0x00007ffa9431aac6 UnrealEditor-UnrealEd.dll!UUnrealEdEngine::Tick() [D:\build++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\UnrealEdEngine.cpp:474]
0x00007ff7187182f6 UnrealEditor.exe!FEngineLoop::Tick() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:5215]
0x00007ff718730d9c UnrealEditor.exe!GuardedMain() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Launch.cpp:183]
0x00007ff718730e8a UnrealEditor.exe!GuardedMainWrapper() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:147]
0x00007ff718733c4d UnrealEditor.exe!LaunchWindowsStartup() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:283]
0x00007ff718745564 UnrealEditor.exe!WinMain() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:330]
0x00007ff718748736 UnrealEditor.exe!__scrt_common_main_seh() [d:\a01_work\6\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
0x00007ffae7d17614 KERNEL32.DLL!UnknownFunction []
0x00007ffae92c26a1 ntdll.dll!UnknownFunction []

I’ll be honest, I have no idea what the issue is, so haven’t been able to resolve it myself.

Any info would be appreciated. :slight_smile:

1 Like

I keep getting the same error, would gladly appreciate some help.

EDIT: Think I figured out the issue, see here: