There’s not much more to it. This is the full code, put it in any actor’s tick function, but you do need a uparameter for the target point:
FCollisionQueryParams TraceParams;
TraceParams.AddIgnoredActor(this);
TraceParams.bTraceComplex = false;
TraceParams.bReturnPhysicalMaterial = false;
FHitResult HitOut;
float Radius = 35.0f;
FVector SphereLoc = RefActor->GetActorLocation();
FVector EndLoc = SphereLoc;
EndLoc.Z += 10.0f;
DrawDebugSphere(GetWorld(), SphereLoc, Radius, 12, FColor::Red, false, -1.0f);
DrawDebugSphere(GetWorld(), EndLoc, Radius, 12, FColor::Yellow, false, -1.0f);
FCollisionResponseParams ResponseParam;
bool Hit = GetWorld()->SweepSingleByChannel(HitOut, SphereLoc, EndLoc, FQuat(0.0f, 0.0f, 0.0f, 1.0f), ECollisionChannel::ECC_Pawn, FCollisionShape::MakeSphere(Radius), TraceParams, ResponseParam);
if (Hit)
{
DrawDebugSphere(GetWorld(), HitOut.Location, 10.0f, 12, FColor::Blue, false, -1.0f);
}
The uparameter in the header file:
UPROPERTY(Category = Node, EditAnywhere)
AActor *RefActor;
So in the editor I simply set thar RefActor to a TargetPoiont. I place the TargetPoint as you see in the image with the two spheres: close to a wall such that both intersect with the same surface.
In the.cpp file of the actor you need an include for the debug draws:
#include "DrawDebugHelpers.h"
Here’s the whole class files: