From bae8955a27c2d70fd7869df95adeec5bcc14b4a6 Mon Sep 17 00:00:00 2001 From: Rafal Swierczek <34179rs@gmail.com> Date: Fri, 20 Oct 2023 14:42:12 +0100 Subject: [PATCH] Fixed Waypoint Appearing for Inactive Checkpoints --- .../Source/EndlessVendetta/BountySystem/BountyClass.cpp | 2 ++ .../Source/EndlessVendetta/BountySystem/CheckpointClass.cpp | 6 +++++- .../Source/EndlessVendetta/BountySystem/CheckpointClass.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyClass.cpp b/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyClass.cpp index fe2a8c58..d21ffbfe 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/BountyClass.cpp @@ -48,6 +48,7 @@ void ABountyClass::SpawnCheckpoints() // Activate the first checkpoint and listen for its completion BountyCheckpoints[0]->Active = true; + BountyCheckpoints[0]->SpawnWaypoint(); BountyCheckpoints[0]->CompletedCheckpoint.AddDynamic(this, &ABountyClass::IncrementBountyCheckpoint); } @@ -84,6 +85,7 @@ void ABountyClass::IncrementBountyCheckpoint() // Set the new checkpoint in pos 0 to be active and listen for it's completion BountyCheckpoints[0]->Active = true; + BountyCheckpoints[0]->SpawnWaypoint(); BountyCheckpoints[0]->CompletedCheckpoint.AddDynamic(this, &ABountyClass::IncrementBountyCheckpoint); } diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/CheckpointClass.cpp b/EndlessVendetta/Source/EndlessVendetta/BountySystem/CheckpointClass.cpp index 393b942b..f544c729 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/CheckpointClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/CheckpointClass.cpp @@ -15,12 +15,16 @@ ACheckpointClass::ACheckpointClass() void ACheckpointClass::BeginPlay() { Super::BeginPlay(); +} + +void ACheckpointClass::SpawnWaypoint() +{ if (!IsValid(WaypointActorClass)) return; FActorSpawnParameters SpawnParams; SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; WaypointActor = Cast(GetWorld()->SpawnActor(WaypointActorClass, WaypointLoc, GetActorRotation(), SpawnParams)); - WaypointActor->SetupWaypoint(WaypointIcon, CheckpointDescription); + WaypointActor->SetupWaypoint(WaypointIcon, CheckpointDescription); } // Called every frame diff --git a/EndlessVendetta/Source/EndlessVendetta/BountySystem/CheckpointClass.h b/EndlessVendetta/Source/EndlessVendetta/BountySystem/CheckpointClass.h index fca979e4..d3a104ff 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BountySystem/CheckpointClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/BountySystem/CheckpointClass.h @@ -48,6 +48,8 @@ public: UPROPERTY(BlueprintReadOnly, Category = "Checkpoint") bool Active = false; + void SpawnWaypoint(); + // ------ Getters for CP Properties ------ FString GetCheckpointDesc() {