How do you shape trace without blueprints?

This is very easy.

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.

3 Likes