Bugfix Player Respawn Defaulting to Player Start over Allocated Respawn Location Randomly
This commit is contained in:
parent
6c2b3d7f29
commit
4ff9305583
@ -13,6 +13,7 @@ void AMainBountyClass::IncrementBountyCheckpoint()
|
||||
if (AOpenWorldCheckpoint* OWCP = Cast<AOpenWorldCheckpoint>(BountyCheckpoints[0]))
|
||||
{
|
||||
OpenWorldRespawnTransform = OWCP->GetRespawnTransform();
|
||||
Ow_RespawnTransform.Broadcast(OpenWorldRespawnTransform);
|
||||
OpenWorldCheckpointClasses.RemoveAt(0);
|
||||
}
|
||||
// FString TipToDisplay = "";
|
||||
@ -51,6 +52,8 @@ void AMainBountyClass::SpawnOpenWorldCheckpoint()
|
||||
BountyCheckpoints.Add(GetWorld()->SpawnActor<ACheckpointClass>(OpenWorldCheckpointClass, Loc, Rot, SpawnParameters));
|
||||
}
|
||||
ActivateFirstCheckpoint();
|
||||
if (BountyCheckpoints.IsEmpty() || BountyCheckpoints[0] == nullptr) return;
|
||||
Ow_RespawnTransform.Broadcast(OpenWorldRespawnTransform);
|
||||
}
|
||||
|
||||
void AMainBountyClass::SpawnCheckpoints()
|
||||
|
@ -35,6 +35,8 @@ struct FMainBountyStruct
|
||||
UTexture2D* Floorplan = nullptr;
|
||||
};
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(F_OW_RespawnTransform, FTransform, RespawnTransform);
|
||||
|
||||
UCLASS()
|
||||
class ENDLESSVENDETTA_API AMainBountyClass : public ABountyClass
|
||||
{
|
||||
@ -66,6 +68,9 @@ public:
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Bounty")
|
||||
FMainBountyStruct MainBountyStruct;
|
||||
|
||||
// Used to Update Open World Respawn in the Bounty Hunter Character
|
||||
F_OW_RespawnTransform Ow_RespawnTransform;
|
||||
|
||||
// ------------------- METHODS ---------------------------------
|
||||
private:
|
||||
// Overrides to Display Correct Tip for Checkpoint
|
||||
|
@ -21,6 +21,7 @@ void ABountyHunterCharacter::SpawnMainBounty(UEVGameInstance* GI)
|
||||
const FAttachmentTransformRules AttachmentTransformRules(EAttachmentRule::SnapToTarget, true);
|
||||
CurrentMainBounty->AttachToComponent(GetRootComponent(), AttachmentTransformRules);
|
||||
CurrentMainBounty->CheckpointActivated.AddDynamic(this, &ABountyHunterCharacter::DisplayCheckpointTip);
|
||||
CurrentMainBounty->Ow_RespawnTransform.AddDynamic(this, &ABountyHunterCharacter::SetOpenWorldRespawnTransform);
|
||||
MainBountyStruct = CurrentMainBounty->MainBountyStruct;
|
||||
if (UGameplayStatics::GetCurrentLevelName(GetWorld()) != OpenWorldLevelName)
|
||||
{
|
||||
@ -136,9 +137,9 @@ void ABountyHunterCharacter::BeginPlay()
|
||||
SpawnSideBounties(GI);
|
||||
if (GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave.GetLocation() != FVector(0 ,0 ,0))
|
||||
{
|
||||
FTransform SpawnTransfrom = GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave;
|
||||
SetActorTransform(SpawnTransfrom);
|
||||
Cast<APlayerController>(GetController())->SetControlRotation(SpawnTransfrom.GetRotation().Rotator());
|
||||
OpenWorldRespawnTransform = GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave;
|
||||
SetActorTransform(OpenWorldRespawnTransform);
|
||||
Cast<APlayerController>(GetController())->SetControlRotation(OpenWorldRespawnTransform.GetRotation().Rotator());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -152,8 +153,6 @@ void ABountyHunterCharacter::SetupPlayerInputComponent(UInputComponent* PlayerIn
|
||||
EnhancedInputComponent->BindAction(PauseMenuAction, ETriggerEvent::Started, this, &ABountyHunterCharacter::TogglePauseMenu);
|
||||
}
|
||||
|
||||
UE_LOG(LogTemp, Warning, TEXT("Setup player input on bounty hunter character"));
|
||||
|
||||
Super::SetupPlayerInputComponent(PlayerInputComponent);
|
||||
}
|
||||
|
||||
@ -166,12 +165,7 @@ void ABountyHunterCharacter::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
||||
if (!IsValid(GI->MainSaveGameInstanceRef)) return;
|
||||
|
||||
if (IsValid(CurrentMainBounty)) GI->MainSaveGameInstanceRef->OpenWorldCheckpointsClassesSave = CurrentMainBounty->GetOpenWorldCheckpointClasses();
|
||||
|
||||
// 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();
|
||||
GI->MainSaveGameInstanceRef->PlayerOpenWorldSpawnTransformSave = OpenWorldRespawnTransform;
|
||||
UGameplayStatics::SaveGameToSlot(GI->MainSaveGameInstanceRef, "MainSave", 0);
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,9 @@ class ENDLESSVENDETTA_API ABountyHunterCharacter : public AEndlessVendettaCharac
|
||||
// Used to Check if all Main Bounties have been completed by the Bounties Tab
|
||||
bool CompletedMainBounties = false;
|
||||
|
||||
// Used to Decide Where in the Open World to Respawn the Player
|
||||
FTransform OpenWorldRespawnTransform;
|
||||
|
||||
protected:
|
||||
|
||||
public:
|
||||
@ -85,6 +88,12 @@ protected:
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void DisplayCheckpointTip(const FString& NewCheckpointTip);
|
||||
|
||||
UFUNCTION()
|
||||
void SetOpenWorldRespawnTransform(FTransform RespawnTransform)
|
||||
{
|
||||
OpenWorldRespawnTransform = RespawnTransform;
|
||||
}
|
||||
|
||||
// Overridden to Setup up Pause Menu Inputs
|
||||
virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user