Static meshes collide with ragdolls in the editor preview

Static meshes can be attached to bones/sockets on a skeleton. When this is done, the mesh is not initialized in the same way as when dropped into a level, and does not get the correct collision profile. For an object with NoCollision selected, it will in fact have collision in the editor preview, which allows it to collide with ragdolls for example.

  • AStaticMeshActor sets “StaticMeshComponent->bUseDefaultCollision = true;” in the ctor
  • FAnimationEditorPreviewScene::AttachObjectToPreviewComponent does not set bUseDefaultCollision and therefore the static mesh’s collision settings are not loaded.

We are fixing this by setting bUseDefaultCollision to true in FAnimationEditorPreviewScene::AttachObjectToPreviewComponent if it is a static mesh

bool FAnimationEditorPreviewScene::AttachObjectToPreviewComponent( UObject* Object, FName AttachTo )
{
...
	TSubclassOf<UActorComponent> ComponentClass = FComponentAssetBrokerage::GetPrimaryComponentForAsset(Object->GetClass());
	if(SkeletalMeshComponent && *ComponentClass && ComponentClass->IsChildOf(USceneComponent::StaticClass()))
	{
...
		USceneComponent* SceneComponent = NewObject<USceneComponent>(WorldSettings, ComponentClass, NAME_None, RF_Transactional);
...
		// 
		// FIX - adds setting bUseDefaultCollision 
		// 

		if (UStaticMeshComponent* StaticMeshComponent = Cast<UStaticMeshComponent>(SceneComponent))		
		{
			    StaticMeshComponent->bUseDefaultCollision = true;		
		}

[Attachment Removed]

Steps to Reproduce

  1. Open a brand new UE 3rd person sample project (tested 5.4.4 and 5.7.3)
  2. Open SKM_Quinn_Simple
  3. Add a static mesh as a preview asset to some bone (e.g. add MaterialSphere on spine_03)
  4. Open the corresponding physics asset (PA_Mannequin)
  5. Simulate the ragdoll, notice that the ragdoll flies off
  6. Close PA_Mannequin
    1. Mesh settings are loaded w/ the asset, need to close and open between changes
  7. Open your attachment asset, e.g MaterialSphere, and apply the NoCollision preset
  8. Re-open PA_Mannequin
  9. Simulate the ragdoll, notice the ragdoll still flies off.
    1. Expected: the added preview asset has no effect on the ragdoll
  10. Optional, drag-and-drop the attachment asset into some test level and see that the collision preset is respected when not used as an attached preview asset

[Attachment Removed]

Hey there,

Thanks for raising this. What you’re doing seems fine, and if it works for you, feel free to keep it. There won’t be large updates to the AnimationEditorPreviewScene so there isn’t much risk of a collision. I’m chatting with the team about whether we want to take this change or something a bit more directly controllable in the window. There might also be a design precedent or reason they decided to go this path that I want to understand.

Dustin

[Attachment Removed]