Hello! I have a scene setup with a high-resolution mesh (16M triangles). I am trying to do some basic raycasting, but the raycasting functionality I’ve written keeps “missing” random parts of the mesh. I am using the LineTraceMultiByChannel
and have tried both the ECC_Visibility and ECC_Worldstatic channels. My mesh is using “Use Complex as Simple” for its collisions, and double-sided geometry. I’ve tried both nanite and non-nanite versions of the mesh. Weirdly, the raycasting works on parts of the mesh, but then passes through other parts? I have been using the following code (copied below), which includes a debug line. I can see the debug line going through parts of the mesh, but they don’t get registered in the “hits”. Is this an issue with the Mesh? Or with the Code? Why would it not register certain parts? I am on UE 5.3.2
Here is the related code:
bool RaycastUtils::RaycastMouse(AKestrelViewerPlayerController* _playerController, TArray& _results) {
UWorld* _world = _playerController->GetWorld();
float _dist = 10000;
FVector _start, _dir;
float _mouseX, _mouseY;
_playerController->GetMousePosition(_mouseX, _mouseY);
_playerController->DeprojectScreenPositionToWorld(_mouseX, _mouseY, _start, _dir);
FVector _end = _start + _dir * _dist;
// Draw debug line to visualize raycast
DrawDebugLine(_world, _start, _end, FColor::Red, false, 5.0f, 0, 1.0f);
FCollisionQueryParams _params(TEXT("TraceParams"));
_params.bTraceComplex = true;
return _world->LineTraceMultiByChannel(_results, _start, _end, ECC_WorldStatic, _params);
}