From c764ce182ad7b6989660542c18b2b4b08bf21797 Mon Sep 17 00:00:00 2001 From: Rafal Swierczek Date: Tue, 3 Oct 2023 12:39:20 +0100 Subject: [PATCH] Fixed LOS Test Missing Actor Reference --- .../ReconGadgets/VisionLink/LOS_Test.uasset | 3 +++ .../VisionLink/RG_VisionLink.uasset | 4 ++-- .../Content/Levels/GadgetSystemTestLevel.umap | 2 +- .../Architecture/Floor_400x400.uasset | 4 ++-- .../StarterContent/Audio/Collapse01.uasset | 4 ++-- .../Recon/VisionLink/VisionLink.cpp | 18 ++++++++++++------ .../VisionLink/VisionLinkEnemyLOSTest.cpp | 8 ++++---- .../Recon/VisionLink/VisionLinkEnemyLOSTest.h | 2 +- 8 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 EndlessVendetta/Content/Gadgets/ReconGadgets/VisionLink/LOS_Test.uasset diff --git a/EndlessVendetta/Content/Gadgets/ReconGadgets/VisionLink/LOS_Test.uasset b/EndlessVendetta/Content/Gadgets/ReconGadgets/VisionLink/LOS_Test.uasset new file mode 100644 index 00000000..8dc51b6b --- /dev/null +++ b/EndlessVendetta/Content/Gadgets/ReconGadgets/VisionLink/LOS_Test.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3dcf2376c901c20297196f292d3af9789583d7023bb529d5e347e29cf43967e1 +size 14705 diff --git a/EndlessVendetta/Content/Gadgets/ReconGadgets/VisionLink/RG_VisionLink.uasset b/EndlessVendetta/Content/Gadgets/ReconGadgets/VisionLink/RG_VisionLink.uasset index a98e94f1..600897ad 100644 --- a/EndlessVendetta/Content/Gadgets/ReconGadgets/VisionLink/RG_VisionLink.uasset +++ b/EndlessVendetta/Content/Gadgets/ReconGadgets/VisionLink/RG_VisionLink.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2a063d83c2d3461bee076adc8e95f993662e0d2cfe542ea8adfec6b524ecde24 -size 97920 +oid sha256:2e54f66125275a7482edeefbb4f92ebba6bc1791877f697fd60c6051711946e7 +size 98220 diff --git a/EndlessVendetta/Content/Levels/GadgetSystemTestLevel.umap b/EndlessVendetta/Content/Levels/GadgetSystemTestLevel.umap index 07001d61..452a38a1 100644 --- a/EndlessVendetta/Content/Levels/GadgetSystemTestLevel.umap +++ b/EndlessVendetta/Content/Levels/GadgetSystemTestLevel.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5e27a9b735217e9310c6c773ebb19ce87a4f00d959f0c4710de79ce8975be500 +oid sha256:e8b0e40ede14db8ce7ce78f51420e587af885afcbc93c4c0e8a24ec6798005ec size 109679 diff --git a/EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset b/EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset index c2a34afc..2a403468 100644 --- a/EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset +++ b/EndlessVendetta/Content/StarterContent/Architecture/Floor_400x400.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4c0ecf0ac0702cc2bd355ec050232a61c49e10f102448efbeb735a51824adef6 -size 14948 +oid sha256:30e523627b30cc7ce8fd4c7a81a580903d0c6689149e9f7cbf39c373d5475a40 +size 14831 diff --git a/EndlessVendetta/Content/StarterContent/Audio/Collapse01.uasset b/EndlessVendetta/Content/StarterContent/Audio/Collapse01.uasset index 198f128d..5e3ff30e 100644 --- a/EndlessVendetta/Content/StarterContent/Audio/Collapse01.uasset +++ b/EndlessVendetta/Content/StarterContent/Audio/Collapse01.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:43d44b5a53fbbfc62522f67ad9523360b15677e3d0caeea96f4d9d0580a013cd -size 353935 +oid sha256:85c827023ee4b466228ec65e92b4b4a0415a106de041ac1c2cab481a2a5dfa8d +size 348532 diff --git a/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetClasses/Recon/VisionLink/VisionLink.cpp b/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetClasses/Recon/VisionLink/VisionLink.cpp index d075a5e3..2aa44fa2 100644 --- a/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetClasses/Recon/VisionLink/VisionLink.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetClasses/Recon/VisionLink/VisionLink.cpp @@ -3,6 +3,10 @@ #include "VisionLink.h" +#include "Camera/CameraComponent.h" +#include "VisionLinkEnemyLOSTest.h" +#include "GameFramework/Character.h" + void AVisionLink::BeginPlay() { Super::BeginPlay(); @@ -38,13 +42,15 @@ void AVisionLink::SendOutPingPulse() UpdatePulsesRemaining(NumOfPingPulsesLeftInThisCycle); if (NumOfPingPulsesLeftInThisCycle < 0) return; - //FActorSpawnParameters SpawnParams; - //SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; - //FVector SpawnLoc = (GetActorLocation() - EquippedOffset) + EnemyLOSTestActor.GetDefaultObject()->SpawnOffset; + FActorSpawnParameters SpawnParams; + SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; + UCameraComponent* PlayerCamComp = Cast(GetWorld()->GetFirstPlayerController()->GetCharacter()->GetComponentByClass(UCameraComponent::StaticClass())); + //FVector SpawnLoc = PlayerCamComp->GetSocketLocation(NAME_None) + PlayerCamComp->GetForwardVector() * EnemyLOSTestActor->GetDefaultObject() - AActor* LOSTestActor = GetWorld()->SpawnActor(EnemyLOSTestActor, SpawnLoc, GetActorRotation(), SpawnParams); - TArray EmptyFStringArray; - Cast(LOSTestActor)->TestLOS(EmptyFStringArray, GetOwner()); + + //AActor* LOSTestActor = GetWorld()->SpawnActor(EnemyLOSTestActor, SpawnLoc, GetActorRotation(), SpawnParams); + //TArray EmptyIDArray; + //Cast(LOSTestActor)->TestLOS(EmptyIDArray, this); UE_LOG(LogTemp, Warning, TEXT("Ping Pulse!")); GetWorld()->GetTimerManager().SetTimer(PulseHandle, this, &AVisionLink::SendOutPingPulse, TimeInbetweenPingPulses, false); diff --git a/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetClasses/Recon/VisionLink/VisionLinkEnemyLOSTest.cpp b/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetClasses/Recon/VisionLink/VisionLinkEnemyLOSTest.cpp index b81b4d54..bb08e273 100644 --- a/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetClasses/Recon/VisionLink/VisionLinkEnemyLOSTest.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetClasses/Recon/VisionLink/VisionLinkEnemyLOSTest.cpp @@ -28,7 +28,7 @@ void AVisionLinkEnemyLOSTest::Tick(float DeltaTime) } -void AVisionLinkEnemyLOSTest::TestLOS(TArray EnemiesInLink, AActor* LOSActor) +void AVisionLinkEnemyLOSTest::TestLOS(TArray EnemiesInLink, AActor* LOSActor) { // Get all overlapping Actors UBoxComponent* CollisionBox = Cast(GetComponentByClass(UBoxComponent::StaticClass())); @@ -47,9 +47,8 @@ void AVisionLinkEnemyLOSTest::TestLOS(TArray EnemiesInLink, AActor* LOS 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]->GetName())) OverlappingEnemies.RemoveAt(i); + if (!OverlappingEnemies[i]->ActorHasTag(FName("Enemy")) || EnemiesInLink.Contains(OverlappingEnemies[i]->GetUniqueID())) OverlappingEnemies.RemoveAt(i); } if (OverlappingEnemies.IsEmpty()) { @@ -59,11 +58,12 @@ void AVisionLinkEnemyLOSTest::TestLOS(TArray EnemiesInLink, AActor* LOS for (AActor* Enemy : OverlappingEnemies) { + if (!IsValid(LOSActor)) UE_LOG(LogTemp, Fatal, TEXT("im an idiot")); FRotator LookAtRotation = UKismetMathLibrary::FindLookAtRotation(LOSActor->GetActorLocation(), Enemy->GetActorLocation()); UE_LOG(LogTemp, Warning, TEXT("Look at Rotation: %f"), LookAtRotation.Yaw); } - Destroy(); + //Destroy(); } diff --git a/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetClasses/Recon/VisionLink/VisionLinkEnemyLOSTest.h b/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetClasses/Recon/VisionLink/VisionLinkEnemyLOSTest.h index c9d6b81a..30475038 100644 --- a/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetClasses/Recon/VisionLink/VisionLinkEnemyLOSTest.h +++ b/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetClasses/Recon/VisionLink/VisionLinkEnemyLOSTest.h @@ -26,5 +26,5 @@ public: // Called every frame virtual void Tick(float DeltaTime) override; - void TestLOS(TArray EnemiesInLink, AActor* LOS_Actor); + void TestLOS(TArray EnemiesInLink, AActor* LOS_Actor); };