From f44915e5f0c3993d57b9b3b5c3e526c72357b918 Mon Sep 17 00:00:00 2001
From: baz <bazzadobs@live.co.uk>
Date: Wed, 26 Mar 2025 21:31:53 +0000
Subject: [PATCH] Fix mysterious timeline playback issues

---
 Content/Pickups/C_Pickup.uasset       | 4 ++--
 Source/vampires/EnemyCharacter.cpp    | 2 +-
 Source/vampires/ObjectPoolManager.cpp | 2 +-
 Source/vampires/Pickup.cpp            | 9 +++++++--
 4 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/Content/Pickups/C_Pickup.uasset b/Content/Pickups/C_Pickup.uasset
index 2987145..31e9b02 100644
--- a/Content/Pickups/C_Pickup.uasset
+++ b/Content/Pickups/C_Pickup.uasset
@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:28a6599953024b26503b69219cf94d39e2ba082a833b9b5f8d202cd03be92970
-size 5054
+oid sha256:a19379aec8a9ba68cb1f5d38d146bf6dc108c6e1638e642f284105bb33e75b88
+size 4964
diff --git a/Source/vampires/EnemyCharacter.cpp b/Source/vampires/EnemyCharacter.cpp
index 05aa617..eece1da 100644
--- a/Source/vampires/EnemyCharacter.cpp
+++ b/Source/vampires/EnemyCharacter.cpp
@@ -55,8 +55,8 @@ void AEnemyCharacter::OnDeath(FDamageInfo damageInfo)
 
 				if (UKismetSystemLibrary::DoesImplementInterface(pickup, UPickupable::StaticClass()))
 				{
-					IPickupable::Execute_LoadDataFromDataAsset(pickup, PickupTemplate);
 					pickup->SetActorLocation(GetActorLocation());
+					IPickupable::Execute_LoadDataFromDataAsset(pickup, PickupTemplate);
 				}
 			}
 		}
diff --git a/Source/vampires/ObjectPoolManager.cpp b/Source/vampires/ObjectPoolManager.cpp
index 70c1291..7c9579f 100644
--- a/Source/vampires/ObjectPoolManager.cpp
+++ b/Source/vampires/ObjectPoolManager.cpp
@@ -14,7 +14,7 @@ void AObjectPoolManager::InitializeObjectPool(TSubclassOf<AActor> Object, const
 {
 	for (int i = 0; i < InitialObjectPoolSize; i++)
 	{
-		AActor* object = GetWorld()->SpawnActor<AActor>(Object);
+		AActor* object = GetWorld()->SpawnActor<AActor>(Object, FVector(10000.0f, 10000.0f, 0), FRotator(0, 0, 0));
 		SetObjectStatus(false, object);
 		ObjectPool.Add(object);
 	}
diff --git a/Source/vampires/Pickup.cpp b/Source/vampires/Pickup.cpp
index 3d37b92..d43fc50 100644
--- a/Source/vampires/Pickup.cpp
+++ b/Source/vampires/Pickup.cpp
@@ -66,7 +66,8 @@ void APickup::LoadDataFromDataAsset_Implementation(UPickupDataAsset* PickupDataA
 		StaticMeshComponent->SetStaticMesh(PickupDataAsset->PickupStaticMesh);
 		PickupSoundBase = PickupDataAsset->PickupSoundBase;
 		CurveFloat = PickupDataAsset->CurveFloat;
-
+		PickupLocation = GetActorLocation();
+		
 		if (CurveFloat != nullptr)
 		{
 			TimelineComponent->AddInterpFloat(CurveFloat, onTimelineCallback);
@@ -107,6 +108,7 @@ void APickup::OnInnerBeginOverlap(UPrimitiveComponent* OverlappedComponent, AAct
 		{
 			if (AObjectPoolManager* objectPoolManager = IPools::Execute_GetProjectileObjectPoolManager(gamemode))
 			{
+				TimelineComponent->Stop();
 				ResetData_Implementation();
 				objectPoolManager->ReturnObject(this);
 			}
@@ -122,7 +124,10 @@ void APickup::OnOuterBeginOverlap(UPrimitiveComponent* OverlappedComponent, AAct
                                   UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep,
                                   const FHitResult& SweepResult)
 {
-	PlayTimeLine();
+	if (!TimelineComponent->IsPlaying() && UGameplayStatics::GetPlayerCharacter(GetWorld(), 0) == Cast<ACharacter>(OtherActor))
+	{
+		PlayTimeLine();
+	}	
 }
 
 void APickup::TimelineCallback(float val)