I’m trying to use OverlapMulti
to build a cover system, but I have a couple of question/issues with using it.
For reference, here’s my code as it currently stands:
GetWorld()->OverlapMulti(overlaps, GetActorLocation(), FQuat::Identity, ECollisionChannel::ECC_WorldStatic, FCollisionShape::MakeSphere(100), FCollisionQueryParams(false));
for (int32 a = 0; a < overlaps.Num(); a++)
{
UBrushComponent *brush = NULL;
brush = static_cast(overlaps[a].Component.Get());
if (brush == 0)
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("component is not a brush"));
}
else
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("component is a brush"));
}
}
- Despite using a CollisionChannel of WorldStatic, this returns the character. Should it not only return static objects?
- The cast to
UBrushComponent
always returns an object, even if the object in question is not a brush and is actually (for example) a static mesh. How can I work out what it actually is that was hit? - How do I go from there, to having the hit location or the closest point on the object to the player?
Thanks.