From 00011764c394b39e71298b4eb02bebcc81c81c3e Mon Sep 17 00:00:00 2001 From: PHILIP WHITE Date: Thu, 9 Nov 2023 13:32:37 +0000 Subject: [PATCH] Add Respawn Point to Prevent Restarting Whole Level --- .../TutorialFacility/RespawnPoint.uasset | 3 +++ EndlessVendetta/Content/Levels/TrainingFacility.umap | 4 ++-- .../EndlessVendetta/EndlessVendettaCharacter.cpp | 12 +++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 EndlessVendetta/Content/BountySystem/TutorialFacility/RespawnPoint.uasset diff --git a/EndlessVendetta/Content/BountySystem/TutorialFacility/RespawnPoint.uasset b/EndlessVendetta/Content/BountySystem/TutorialFacility/RespawnPoint.uasset new file mode 100644 index 00000000..cfefe2d6 --- /dev/null +++ b/EndlessVendetta/Content/BountySystem/TutorialFacility/RespawnPoint.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ddfaf161972d5ed7da321d0764e3887dd4b91ef6d6e294ed590f8645bd5c1e01 +size 22117 diff --git a/EndlessVendetta/Content/Levels/TrainingFacility.umap b/EndlessVendetta/Content/Levels/TrainingFacility.umap index c523e676..173b21c6 100644 --- a/EndlessVendetta/Content/Levels/TrainingFacility.umap +++ b/EndlessVendetta/Content/Levels/TrainingFacility.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:42694d3853709ed696985ab999b7d2b28cfb8f582c44af989bac7e694fbfe9ed -size 622312 +oid sha256:025f2af1652f9d8f05c2bd2d98e928643385f8df9fdd12b974730607629f7053 +size 623170 diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp index 98db3135..97bbe387 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp @@ -204,8 +204,18 @@ float AEndlessVendettaCharacter::TakeDamage(const float DamageAmount, FDamageEve GetWorld()->GetTimerManager().ClearTimer(RegenHealthTimerHandle); } UE_LOG(LogTemp, Warning, TEXT("Player is dead")); - UGameplayStatics::OpenLevel(this, FName(*GetWorld()->GetName()), false); + TArray FoundActors; + UGameplayStatics::GetAllActorsWithTag(GetWorld(), FName(TEXT("Respawn")), FoundActors); + if (FoundActors.Num() > 0) + { + const AActor* RespawnPoint = FoundActors[0]; + SetActorLocationAndRotation(RespawnPoint->GetActorLocation(), RespawnPoint->GetActorRotation()); + CurrentHealth = MaxHealth; + return Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser); + } + + UGameplayStatics::OpenLevel(this, FName(*GetWorld()->GetName()), false); return Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser); }