Reload Current Level on Character Destruction
This commit is contained in:
parent
925be65769
commit
bff484f139
|
@ -4,6 +4,7 @@
|
|||
#include "PlayerCharacter.h"
|
||||
// You can remove these, this is just to get intellisense to work
|
||||
#include <Components/CapsuleComponent.h>
|
||||
#include <Kismet/GameplayStatics.h>
|
||||
|
||||
#include "InputTriggers.h"
|
||||
#include "EnhancedInputComponent.h"
|
||||
|
@ -77,6 +78,13 @@ void APlayerCharacter::BeginPlay()
|
|||
}
|
||||
}
|
||||
|
||||
void APlayerCharacter::Destroyed()
|
||||
{
|
||||
Super::Destroyed();
|
||||
|
||||
UGameplayStatics::OpenLevel(GetWorld(), FName(GetWorld()->GetMapName()));
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
void APlayerCharacter::Tick(float DeltaTime)
|
||||
{
|
||||
|
@ -318,7 +326,6 @@ void APlayerCharacter::OnDamaged()
|
|||
void APlayerCharacter::OnDeath()
|
||||
{
|
||||
Super::OnDeath();
|
||||
UE_LOG(LogTemp, Error, TEXT("YOU ARE DEAD!"));
|
||||
|
||||
this->DetachFromControllerPendingDestroy();
|
||||
this->GetCapsuleComponent()->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
||||
|
|
|
@ -91,6 +91,8 @@ protected:
|
|||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
virtual void Destroyed() override;
|
||||
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue