Changing BodyInstance Collision Profile Does Not Change the Physics Query Type

When changing the Collision Profile of a skeletal mesh in C++ the collision query type is not effected.

Expectation: I can change collision profile preset and the collision query field changes with the preset the same as the blueprint version.

This bug has actually been around a while and I always suspected it was just me doing something wrong but after properly testing I am positive this is a bug within the C++ implementation.

The data highlighted in Red is not changed when you use C++ to change the collision preset

CPP Code Approach

122984-bugreport.png

Blueprint Equivalent

Reproduction Steps to confirm this bug:

  • Create the Third Person Template
    Project.
  • By default the CharacterMesh preset
    will be set on your skeletal mesh
    with Query Only enabled.
  • Bind a key to trigger the CPP code
    approach (listed above) to enter the
    ragdoll state see the result.
  • Bind a key to trigger a blueprint
    approach (listed above) to enter the
    ragdoll state and see the result.
  • Now edit the CharacterMesh preset so
    the Collision is Query & Physics, you
    will now see the correct behaviour.

It appears somehow that through code it always uses the original mesh’s collision query type.

Kind regards,

Jakey113G

EDIT:
I tried to use the following call and it too failed to change my collision query type.

122989-backup_solution.png

Hey Jackey113G-

I have moved your solution from the original post here so that others who comes across this post can clearly see what your solution was:

SOLUTION

So I was confused for a while on what was actually wrong. I investigated the source code and realised the issue. The problem isn’t a bug.

In the UStaticMeshComponent there is a valid method to change the collision profile which calls a super UPrimitiveFunction called SetCollisionProfileName (Stored in the PrimitiveComponentPhysics class), this is the real implementation needed to change a collision profile. Inside that function is this:

123064-primitive_impl_profilechange.png

The key thing I was missing in my above code is that I was not calling OnComponentCollisionSettingsChanged(). I also noticed the comment with a note to add a functional equivalent for skeletal mesh so to change the profile it could be done in a single call similar to the UStaticMeshComponents implementation.

Sorry for mistaking this as a bug, I got confused with SetCollisionProfileName of static mesh and that which is missing for skeletal meshes.