I need to check a box shaped area in front of my player for multiple objects.
I’m looking everywhere for documentation on shape tracing in C++ (or even just using shape components to check for overlap) and there doesn’t seem to be anything. No matter what I search, all I can find is information about line tracing or raycasting.
First of all you need have to create the shape you want to trace.
FCollisionShape Shape = FCollisionShape::MakeBox(FVector(50,50,50));
Then you have to declare your hit result.
FHitResult SweepResult;
To trace you just do the following:
GetWorld()->SweepSingleByChannel(SweepResult, StartLocation, EndLocation, ShapeRotation, ECC_Visible, Shape)
this returns true if the sweep hit something. If that is the case you can use the SweepResult object to get more information about what you hit. If you want to know about all hits use SweepMultiByChannel. That takes an array of FHitResult.