I have a 2D sprite that has two collision shapes defined. In my code I am referencing the UPaperFlipbookComponent
and performing overlap checks (using 3D physics) with something along these lines:
AActor *AHeroPawn::CollideFirst(float x, float z) {
AActor *res = NULL;
FVector originalLocation = GetActorLocation();
FVector newLocation = GetActorLocation();
newLocation.X = x;
newLocation.Z = z;
SetActorLocation(newLocation);
TArray<AActor *> actors;
Sprite->GetOverlappingActors(actors, NULL);
for (auto CompIt = actors.CreateIterator(); CompIt; ++CompIt) {
UE_LOG(LogTemp, Warning, TEXT("Overlapping actor."));
AActor *OverlappingActor = *CompIt;
if (OverlappingActor != this) {
UE_LOG(LogTemp, Warning, TEXT("Actor: %s"), *AActor::GetDebugName(OverlappingActor));
res = OverlappingActor;
}
}
SetActorLocation(originalLocation);
return res;
}
This is working fine as long as I have just one collision shape. The moment I have two shapes (i.e. one for world collision and one as enemy hitbox) it looks like GetOverlappingActors
is using either all the shapes or the biggest or just the first as my first one is the biggest.
I’d rather have it perform overlap checks using the collision shape I tell it to. Is there any way to accomplish this?
Another way could be to enumerate the collision shapes and be able to enable/disable them before performing the overlap check, but I couldn’t find a method to get the list of the collision shapes.
Thanks in advance for any help!