Fixed Issue with Searching Actor Array in LOS Test

Temp solution, a work around for quickly finding a specific actor in array
This commit is contained in:
Rafal Swierczek 2023-10-02 09:23:38 +01:00
parent 81a8c2ae44
commit c0cc7c4782
5 changed files with 10 additions and 9 deletions

Binary file not shown.

View File

@ -43,8 +43,8 @@ void AVisionLink::SendOutPingPulse()
FVector SpawnLoc = (GetActorLocation() - EquippedOffset) + EnemyLOSTestActor.GetDefaultObject()->SpawnOffset;
AActor* LOSTestActor = GetWorld()->SpawnActor<AActor>(EnemyLOSTestActor, SpawnLoc, GetActorRotation(), SpawnParams);
TArray<AActor> EmptyActorArray;
Cast<AVisionLinkEnemyLOSTest>(LOSTestActor)->TestLOS(EmptyActorArray, GetOwner());
TArray<FString> EmptyFStringArray;
Cast<AVisionLinkEnemyLOSTest>(LOSTestActor)->TestLOS(EmptyFStringArray, GetOwner());
UE_LOG(LogTemp, Warning, TEXT("Ping Pulse!"));
GetWorld()->GetTimerManager().SetTimer(PulseHandle, this, &AVisionLink::SendOutPingPulse, TimeInbetweenPingPulses, false);

View File

@ -28,7 +28,7 @@ void AVisionLinkEnemyLOSTest::Tick(float DeltaTime)
}
void AVisionLinkEnemyLOSTest::TestLOS(TArray<AActor> EnemiesInLink, AActor* LOSActor)
void AVisionLinkEnemyLOSTest::TestLOS(TArray<FString> EnemiesInLink, AActor* LOSActor)
{
// Get all overlapping Actors
UBoxComponent* CollisionBox = Cast<UBoxComponent>(GetComponentByClass(UBoxComponent::StaticClass()));
@ -47,8 +47,9 @@ void AVisionLinkEnemyLOSTest::TestLOS(TArray<AActor> EnemiesInLink, AActor* LOSA
for (int i = 0; i < OverlappingEnemies.Num(); i++)
{
UE_LOG(LogTemp, Warning, TEXT("Overlapping Enemy Name: %s"), *OverlappingEnemies[i]->GetName());
// Overlapping Enemies Array should only contain enemies which aren't already in the link
if (!OverlappingEnemies[i]->ActorHasTag(FName("Enemy")) || EnemiesInLink.Contains(OverlappingEnemies[i])) OverlappingEnemies.RemoveAt(i);
if (!OverlappingEnemies[i]->ActorHasTag(FName("Enemy")) || EnemiesInLink.Contains(OverlappingEnemies[i]->GetName())) OverlappingEnemies.RemoveAt(i);
}
if (OverlappingEnemies.IsEmpty())
{

View File

@ -26,5 +26,5 @@ public:
// Called every frame
virtual void Tick(float DeltaTime) override;
void TestLOS(TArray<AActor> EnemiesInLink, AActor* LOS_Actor);
void TestLOS(TArray<FString> EnemiesInLink, AActor* LOS_Actor);
};