I am trying to perform SweepSingleByChannel on an actor’s location by placing a box around it. My DrawDebugBox works fine but the SweepSingleByChannelDoesnt Seems to be behaving properly.
void ATile::TrialBounds(AActor* ActorToTrial)
{
FVector Origin;
FVector Extend;
FHitResult HitResult;
ActorToTrial->GetActorBounds(false, Origin, Extend);
bool hashit = GetWorld()->SweepSingleByChannel(HitResult, Origin, Origin, FQuat::Identity, ECC_GameTraceChannel2, FCollisionShape::MakeBox(Extend));
FColor ResultColor;
if (hashit) {
ResultColor = FColor::Red;
}
else {
ResultColor = FColor::Green;
}
DrawDebugBox(GetWorld(), Origin, Extend, ResultColor, false, 100);
}
Below is what happens in the game
Ideally, the sack on the left should be highlighted with a red box indicating that the box has hit the wall. I have checked the wall to ensure its collision setting blocks the trace channel used.
My guess is that i have implemented the SweepSingleByChannel function wrongly, would be grateful if anyone can point out my mistake