Problem with Line Trace and Instanced Static Mesh Components. The first attempt fails

I have a weird problem with lineTraces and instances mesh components. I will try to explain the best I can…

I have a function which perform a single linetrace againts an instanced mesh component in order to delete the specific instance hit.

This function is called inside a loop and its working fine except for the first time. The algorithm is called at the BeginPlay event but I’ve used a timer as well to check whether is a problem about the creation order (instanced meshes are not ready when I do the linetrace or whatever…). it didn’t work either even few seconds after the game started.

The rest of the iterations are working properly. The only which is failing is the first one but if I call again that function on this element after the “main” loop it works this time.
So, it don’t seems a problem with this specific element, just that something is happening with the physics engine the first time.

Did you face something similar?? any idea or advice??

Thanks

Just to add some info:

I’m drawing debug lines for each line trace and it seems clearly that it should hit but it doesn’t (the first attempt).

Regards

I have the same issue when creating Terrain with Instanced Static Meshes. I want to place some trees but the line traces go through the Instanced Mesh.
As this Question is a long time ago, did you find any solution?

I’m noticing this too - foot IK using line traces is not working on instanced static meshes.

This is an old post, but comes up high on google results for this issue:

If you are doing a trace against an Instance Static Mesh you should check if “btracecomplex” is set to true. if it is, the trace is going to fail. Set it to false, and the trace should succeed, assuming everything else is set up correctly.

2 Likes

Wow Thanks! Indeed it worked in my case.
Symptoms: some of my static mesh (turn out to be instances) were not colliding with the LineTrace.
With bTraceComplex = false, it now works.
My setup :

ECollisionChannel const CollisionChannel = ECollisionChannel::ECC_Visibility;
FHitResult HitResult;
FCollisionQueryParams CollisionQueryParams = FCollisionQueryParams::DefaultQueryParam;
CollisionQueryParams.bTraceComplex = false;

bool const bHit = World->LineTraceSingleByChannel(HitResult, Start, End, CollisionChannel, CollisionQueryParams); 

image

Checklist for debugging:

  1. Check collision preset: Does your mesh has the correct Object type and profile (see screenshot)
  2. Check collision shape: Does your mesh has a simple collision (On the static mesh: show simple collision)
  3. Check trace: Is your trace really passing through the mesh
  4. Check C++ code: Is bTraceComplex is false and CollisionChannel on a correct channel
1 Like