How to create mesh blocked by line trace which character can walk through?

I am using the C++ routine UProceduralMeshComponent::CreateMeshSection to create meshes.

  • If I pass bCreateCollision=true my character won’t pass through the mesh, and LineTraceByChannel will detect it.
  • If I pass bCreateCollision=false my character will pass through the mesh, and LineTraceByChannel won’t detect it.

How do I create a mesh which my character will pass through the mesh, but LineTraceByChannel will detect? If it matters, I’m using the Trace Channel ‘Visibility’.

Thank you.

Hi,
there’s a simple solution to your problem.
You need to set up a custom collision channel for either the mesh or your player.
Then have the player set to not collide with it and the trace channel to your custom one.
Heres the official Unreal Documentation: Collision Filtering

Hope I could help, have a nice day.

My question is specifically about meshes generated with C++. I’m unsure how to use the site you referenced to modify the collision response properties of real-time C++ generated meshes.

I have found a solution. I’ll give credit to Wojtt with their post >here<.

The solution comes in three parts. #2 is the critical call!

  1. When calling CreateMeshSection (or CreateMeshSection_LinearColor), specify bCreateCollision=true.
  2. Call your UProceduralMeshComponent’s SetCollisionProfileName passing in the name of the preset collision profile. If you need to, you can create custom collision profiles through the process shown >here<.
  3. Use different UProceduralMeshComponents for different objects which require different collision profiles.