I’m using line trace to do some calculations. It’s used from C++ during the editor time. Whole scene is loaded using custom factory (i.e. meshes are created via custom classes not via fbx importer).
So, when I import everything first time and do line traces everything works fine. I can repeat calculations, unload and load level again and still works fine.
Based on the code provided, you’re using the depreciated version of the LineTraceSingle() function. Try using UKismetSystemLibrary::LineTraceSingle_NEW(); instead to see if that helps.
bool UKismetSystemLibrary::LineTraceSingle_NEW(UObject* WorldContextObject, const FVector Start, const FVector End, ETraceTypeQuery TraceChannel, bool bTraceComplex, const TArray<AActor*>& ActorsToIgnore, EDrawDebugTrace::Type DrawDebugType, FHitResult& OutHit, bool bIgnoreSelf, FLinearColor TraceColor, FLinearColor TraceHitColor, float DrawTime)
{
return LineTraceSingle_DEPRECATED(WorldContextObject, Start, End, UEngineTypes::ConvertToCollisionChannel(TraceChannel), bTraceComplex, ActorsToIgnore, DrawDebugType, OutHit, bIgnoreSelf, TraceColor, TraceHitColor, DrawTime);
}
That’s how old and new functions are related, they’re basically the same. And I totally don’t understand what to pass as ETraceTypeQuery TraceChannel, and there’s zero info about this.
OK, during my calculations I was rebuilding static mesh components. So to make everything work I had to reinit BodySetup of the static mesh (collision part of it). Case closed.