How do you shape trace without blueprints???
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.
https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UseRaycasts/Blueprints/#shapetraces I found that you can include kismet libraries to use blueprint functions, but I haven't found any way to look up how those functions would appear in C++.
I found these functions: https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Engine/UWorld/ComponentOverlapMulti/1/index.html https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Engine/UWorld/ComponentSweepMulti/1/index.html but they don't include any examples and I don't understand how the syntax works from these pages.
I'm at a loss and I would much rather keep my shape tracing in C++ than blueprints. I appreciate any help or direction, thanks.
edit: this looks promising: https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Engine/UWorld/SweepMultiByChannel/index.html but I still don't understand how the parameters work. I'll keep trying in the meantime.
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.
answered Jul 11 '17 at 10:30 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here