Skip to content

Instantly share code, notes, and snippets.

@Maxime66410
Last active April 27, 2025 15:27
Show Gist options
  • Save Maxime66410/e7c8ed6b9a7c0e40dcecb7528439d91b to your computer and use it in GitHub Desktop.
Save Maxime66410/e7c8ed6b9a7c0e40dcecb7528439d91b to your computer and use it in GitHub Desktop.
Create a box trace V2
FVector WorldCenter = Mesh->GetComponentLocation(); // Get the center of the mesh
FVector SweepExtent = Mesh->GetStaticMesh()->GetBounds().BoxExtent; // Get the extent of the mesh
FCollisionShape BoxCollision = FCollisionShape::MakeBox(SweepExtent);
GetWorld()->SweepSingleByChannel(HitResult, WorldCenter, WorldCenter, FRotator(), ECC_WorldStatic, BoxCollision, QueryParams);
DrawDebugBox(GetWorld(), WorldCenter, SweepExtent, FRotator(), FColor::Red, false, 2.0f); // Draw a debug box around the mesh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment