diff --git a/Source/Nakatomi/PlayerCharacter.cpp b/Source/Nakatomi/PlayerCharacter.cpp index 7db8913..766a388 100644 --- a/Source/Nakatomi/PlayerCharacter.cpp +++ b/Source/Nakatomi/PlayerCharacter.cpp @@ -4,6 +4,7 @@ #include "PlayerCharacter.h" // You can remove these, this is just to get intellisense to work #include +#include #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); diff --git a/Source/Nakatomi/PlayerCharacter.h b/Source/Nakatomi/PlayerCharacter.h index 665dea2..df0d773 100644 --- a/Source/Nakatomi/PlayerCharacter.h +++ b/Source/Nakatomi/PlayerCharacter.h @@ -91,6 +91,8 @@ protected: virtual void BeginPlay() override; public: + virtual void Destroyed() override; + // Called every frame virtual void Tick(float DeltaTime) override;