Created
April 27, 2025 15:29
-
-
Save Maxime66410/0701ff404d5621fe79c1c735992836d5 to your computer and use it in GitHub Desktop.
Create a box trace V4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FHitResult HitResult; | |
FVector WorldCenter = Mesh->GetComponentLocation(); // Get the center of the meshFVector | |
SweepExtent = Mesh->GetStaticMesh()->GetBounds().BoxExtent; // Get the extent of the meshFRotator | |
ActorRotation = Mesh->GetComponentRotation(); // Get the rotation of the meshFQuat | |
QuatRotation = FQuat(ActorRotation); // Convert the rotation to a quaternion | |
SweepExtent += FVector(5.0f, 5.0f, 5.0f); // Add a little extra to the extent | |
FCollisionQueryParams QueryParams; | |
QueryParams.AddIgnoredActor(this); | |
QueryParams.bTraceComplex = true; | |
FCollisionShape BoxCollision = FCollisionShape::MakeBox(SweepExtent); | |
GetWorld()->SweepSingleByChannel(HitResult, WorldCenter, WorldCenter, QuatRotation, ECC_WorldStatic, BoxCollision, QueryParams); | |
DrawDebugBox(GetWorld(), WorldCenter, SweepExtent, QuatRotation, FColor::Red, false, 2.0f); // Draw a debug box to visualize the sweep | |
if(!HitResult.bBlockingHit) | |
{ | |
DestroyBarricade(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment