Restart implemented
Added the restart level functionality binding to the R key to test the game without stopping the engine
This commit is contained in:
parent
4dcec8140a
commit
183adf599b
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:eae19cff0d1a7ec399f2bed7ddebeb12a0cd1464b7cc3aac8997e573ce9f340f
|
||||
size 35109
|
||||
oid sha256:96b498c17899f18649d1af2a84fb121464381a57d2c720e1b67754a4c459cd5a
|
||||
size 35291
|
||||
|
||||
3
Content/Input/Actions/Restart.uasset
Normal file
3
Content/Input/Actions/Restart.uasset
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ef291271c7b8103e8cdbba9da0e9eda6b6373ff0eee807e60611f2ad9db4b52e
|
||||
size 1326
|
||||
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e74d6ed0dfcdf4c8763e8adcdbba02a4ddccea77272d024f064ff50f9d288c8b
|
||||
size 4382
|
||||
oid sha256:da11530fbc1a44bde5eed884dd45e343c6a6bc6e85e5d8ef8dd4f2989067ed62
|
||||
size 5608
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
#include "EndlessZombieGameMode.h"
|
||||
#include "EndlessZombieCharacter.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "UObject/ConstructorHelpers.h"
|
||||
|
||||
AEndlessZombieGameMode::AEndlessZombieGameMode()
|
||||
@ -13,3 +14,9 @@ AEndlessZombieGameMode::AEndlessZombieGameMode()
|
||||
DefaultPawnClass = PlayerPawnBPClass.Class;
|
||||
}
|
||||
}
|
||||
|
||||
void AEndlessZombieGameMode::RestartLevel()
|
||||
{
|
||||
FName LevelName = FName(GetWorld()->GetCurrentLevel()->GetName());
|
||||
UGameplayStatics::OpenLevel(GetWorld(), LevelName);
|
||||
}
|
||||
|
||||
@ -13,6 +13,8 @@ class AEndlessZombieGameMode : public AGameModeBase
|
||||
|
||||
public:
|
||||
AEndlessZombieGameMode();
|
||||
|
||||
void RestartLevel();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -42,9 +42,6 @@ void AObstacle::CollisionBeginOverlap(UPrimitiveComponent* OverlappedComponent,
|
||||
{
|
||||
if (OtherActor->IsA(AZombieCharacter::StaticClass()))
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("[AObstacle::CollisionBeginOverlap] Se ha chocao Paco"));
|
||||
GEngine->AddOnScreenDebugMessage(-1, 3.0f, FColor::Red, TEXT("Se ha chocao Paco"));
|
||||
|
||||
AZombieCharacter* ZombieCharacter = Cast<AZombieCharacter>(OtherActor);
|
||||
ZombieCharacter->Die();
|
||||
}
|
||||
|
||||
@ -2,14 +2,16 @@
|
||||
|
||||
|
||||
#include "ZombieCharacter.h"
|
||||
#include "EndlessZombieGameMode.h"
|
||||
#include "Camera/CameraComponent.h"
|
||||
#include "Components/CapsuleComponent.h"
|
||||
#include "Components/InputComponent.h"
|
||||
#include "GameFramework/CharacterMovementComponent.h"
|
||||
#include "GameFramework/Controller.h"
|
||||
#include "GameFramework/SpringArmComponent.h"
|
||||
#include "EnhancedInputComponent.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "EnhancedInputSubsystems.h"
|
||||
#include "GameFramework/Controller.h"
|
||||
#include "Components/InputComponent.h"
|
||||
#include "Components/CapsuleComponent.h"
|
||||
#include "GameFramework/SpringArmComponent.h"
|
||||
#include "GameFramework/CharacterMovementComponent.h"
|
||||
|
||||
// Sets default values
|
||||
AZombieCharacter::AZombieCharacter()
|
||||
@ -96,12 +98,12 @@ void AZombieCharacter::Tick(float DeltaTime)
|
||||
if (!bDied)
|
||||
{
|
||||
|
||||
TurnTimeline.TickTimeline(DeltaTime);
|
||||
TurnTimeline.TickTimeline(DeltaTime);
|
||||
|
||||
if (!bTurning)
|
||||
{
|
||||
MoveForwardConstant(DeltaTime);
|
||||
}
|
||||
if (!bTurning)
|
||||
{
|
||||
MoveForwardConstant(DeltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,6 +125,9 @@ void AZombieCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCom
|
||||
//EnhancedInputComponent->BindAction(CrouchAction, ETriggerEvent::Triggered, this, &AZombieCharacter::Crouch);
|
||||
//EnhancedInputComponent->BindAction(CrouchAction, ETriggerEvent::Triggered, this, &ACharacter::);
|
||||
//EnhancedInputComponent->BindAction(CrouchAction, ETriggerEvent::Completed, this, &ACharacter::StopCrouching);
|
||||
|
||||
// RestartLevel
|
||||
EnhancedInputComponent->BindAction(RestartAction, ETriggerEvent::Started, this, &AZombieCharacter::RestartLevel);
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,6 +153,15 @@ void AZombieCharacter::Move(const FInputActionValue& Value)
|
||||
}
|
||||
}
|
||||
|
||||
void AZombieCharacter::RestartLevel()
|
||||
{
|
||||
AEndlessZombieGameMode* CurrentGameMode = Cast<AEndlessZombieGameMode>(UGameplayStatics::GetGameMode(GetWorld()));
|
||||
if (CurrentGameMode)
|
||||
{
|
||||
CurrentGameMode->RestartLevel();
|
||||
}
|
||||
}
|
||||
|
||||
//void AZombieCharacter::Crouch(const FInputActionValue& Value)
|
||||
//{
|
||||
//
|
||||
|
||||
@ -36,6 +36,9 @@ class ENDLESSZOMBIE_API AZombieCharacter : public ACharacter
|
||||
/** Crouch Input Action */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
||||
class UInputAction* CrouchAction;
|
||||
// Restart Input Action
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
||||
class UInputAction* RestartAction;
|
||||
|
||||
public:
|
||||
// Sets default values for this character's properties
|
||||
@ -50,6 +53,7 @@ protected:
|
||||
|
||||
void Move(const FInputActionValue& Value);
|
||||
//void Crouch(const FInputActionValue& Value);
|
||||
void RestartLevel();
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
|
||||
Loading…
Reference in New Issue
Block a user