Implemented Open World Checkpoint Respawns

This commit is contained in:
Rafal Swierczek 2024-03-20 00:47:24 +00:00
parent 1f2243134f
commit 2cc1d566a6
12 changed files with 50 additions and 21 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:d96dde71ce13d7ed2661e3fe8d0531e67453e81644492f026f7577c12af0acf9 oid sha256:ffc0494e896f842e6d6baa4953b6f317c3e2479d2b672611671fdc12fb184555
size 35286 size 35802

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:a6edb31abcafeab6442cb285181905031da2635eb7c6444b529d9c8636ee9496 oid sha256:253f8ebabbd32167aa4ecd182352cb52f1c337502351a1bd8f38414f6b3a9d61
size 29747 size 29197

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:7367fb8f5ccaf3e4ae6e34133debe0d5efbaedf33024d14cf37b1f4f5ff7fb1c oid sha256:1c22f439331d8787e77de31ada2719cc99dd341a7a0564eeb9bd3f8fcafcc2f2
size 39283 size 38592

Binary file not shown.

View File

@ -17,4 +17,10 @@ class ENDLESSVENDETTA_API AOpenWorldCheckpoint : public ACheckpointClass
protected: protected:
UPROPERTY(EditDefaultsOnly, Category = "Checkpoint") UPROPERTY(EditDefaultsOnly, Category = "Checkpoint")
FTransform RespawnTransform; FTransform RespawnTransform;
public:
FTransform GetRespawnTransform()
{
return RespawnTransform;
}
}; };

View File

@ -3,10 +3,17 @@
#include "MainBountyClass.h" #include "MainBountyClass.h"
#include "CheckPoints/OpenWorldCheckpoint.h"
void AMainBountyClass::IncrementBountyCheckpoint() void AMainBountyClass::IncrementBountyCheckpoint()
{ {
Super::IncrementBountyCheckpoint(); Super::IncrementBountyCheckpoint();
CompletedACheckpoint.Broadcast(); CompletedACheckpoint.Broadcast();
if (BountyCheckpoints.IsEmpty() || !IsValid(BountyCheckpoints[0])) return;
if (AOpenWorldCheckpoint* OWCP = Cast<AOpenWorldCheckpoint>(BountyCheckpoints[0]))
{
OpenWorldRespawnTransform = OWCP->GetRespawnTransform();
}
// FString TipToDisplay = ""; // FString TipToDisplay = "";
// if (!Completed) TipToDisplay = BountyCheckpoints[0]->GetCheckpointTip(); // if (!Completed) TipToDisplay = BountyCheckpoints[0]->GetCheckpointTip();
// Cast<AEndlessVendettaCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn())->CheckpointCompletedUI("", false); // Cast<AEndlessVendettaCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn())->CheckpointCompletedUI("", false);

View File

@ -54,6 +54,9 @@ class ENDLESSVENDETTA_API AMainBountyClass : public ABountyClass
// Used to Spawn Side Bounties Associated with this Main Bounty // Used to Spawn Side Bounties Associated with this Main Bounty
UPROPERTY(EditDefaultsOnly, Category = "Bounty") UPROPERTY(EditDefaultsOnly, Category = "Bounty")
TArray<TSubclassOf<ASideBountyClass>> SideBountiesToSpawn; TArray<TSubclassOf<ASideBountyClass>> SideBountiesToSpawn;
// Used by Bounty Char to determine where to respawn the player based on what checkpoint they're at
FTransform OpenWorldRespawnTransform;
protected: protected:
@ -94,6 +97,10 @@ public:
// Overrides to Desapwn Waypoint from OpenWorld Checkpoint // Overrides to Desapwn Waypoint from OpenWorld Checkpoint
void DeActivateFirstCheckpoint() override; void DeActivateFirstCheckpoint() override;
FTransform GetOpenWorldRespawnTransform()
{
return OpenWorldRespawnTransform;
}
// Returns open world checkpoints tip // Returns open world checkpoints tip
// FString GetOpenWorldCheckpointTip() // FString GetOpenWorldCheckpointTip()
// { // {

View File

@ -133,11 +133,14 @@ void ABountyHunterCharacter::BeginPlay()
InOpenWorld = true; InOpenWorld = true;
SpawnBikeUI(); SpawnBikeUI();
SpawnSideBounties(GI); SpawnSideBounties(GI);
if (GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave.GetLocation() != FVector(0 ,0 ,0))
{
FTransform SpawnTransfrom = GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave; FTransform SpawnTransfrom = GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave;
SetActorTransform(SpawnTransfrom); SetActorTransform(SpawnTransfrom);
Cast<APlayerController>(GetController())->SetControlRotation(SpawnTransfrom.GetRotation().Rotator()); Cast<APlayerController>(GetController())->SetControlRotation(SpawnTransfrom.GetRotation().Rotator());
} }
} }
}
CreatePauseMenuTabs(); CreatePauseMenuTabs();
} }
@ -157,9 +160,15 @@ void ABountyHunterCharacter::EndPlay(const EEndPlayReason::Type EndPlayReason)
{ {
Super::EndPlay(EndPlayReason); Super::EndPlay(EndPlayReason);
if (UGameplayStatics::GetCurrentLevelName(GetWorld()) != OpenWorldLevelName) return; if (UGameplayStatics::GetCurrentLevelName(GetWorld()) != OpenWorldLevelName) return;
UEVGameInstance* GI = Cast<UEVGameInstance>(GetGameInstance()); UEVGameInstance* GI = Cast<UEVGameInstance>(GetGameInstance());
if (!IsValid(GI->MainSaveGameInstanceRef)) return; if (!IsValid(GI->MainSaveGameInstanceRef)) return;
GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave = GetActorTransform();
// if main bounty exists, save its locally stored open world respawn transform
// otherwise, store it as 0,0,0 which will make the player spawn at player start instead
FTransform EmptyTransform;
GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave = IsValid(CurrentMainBounty) ? CurrentMainBounty->GetOpenWorldRespawnTransform() : EmptyTransform;
//GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave = GetActorTransform();
UGameplayStatics::SaveGameToSlot(GI->MainSaveGameInstanceRef, "MainSave", 0); UGameplayStatics::SaveGameToSlot(GI->MainSaveGameInstanceRef, "MainSave", 0);
} }