Main menu to in game flow

This commit is contained in:
Kevin Poretti 2023-01-09 17:42:12 -05:00
parent 1123ba8ff7
commit 707804bf54
14 changed files with 46 additions and 51 deletions

Binary file not shown.

Binary file not shown.

BIN
GravityStomp/Content/Core/BP_GSGameState.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
GravityStomp/Content/Maps/Debug/Test.umap (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -39,19 +39,6 @@ AGSCharacter::AGSCharacter(const FObjectInitializer& ObjectInitializer)
GetCharacterMovement()->MinAnalogWalkSpeed = 20.f;
GetCharacterMovement()->BrakingDecelerationWalking = 2000.f;
// Create a camera boom (pulls in towards the player if there is a collision)
CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
CameraBoom->SetupAttachment(RootComponent);
CameraBoom->TargetArmLength = 400.0f; // The camera follows at this distance behind the character
CameraBoom->bUsePawnControlRotation = false; // Rotate the arm based on the controller
CameraBoom->SetWorldRotation(FVector::ForwardVector.Rotation());
// Create a follow camera
FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));
FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation
FollowCamera->bUsePawnControlRotation = false; // Camera does not rotate relative to arm
// Note: The skeletal mesh and anim blueprint references on the Mesh component (inherited from Character)
// are set in the derived blueprint asset named ThirdPersonCharacter (to avoid direct content references in C++)
}
@ -126,3 +113,22 @@ void AGSCharacter::ChangeGravityDirection(const FInputActionValue& Value)
GetCharacterMovement<UGSCharacterMovementComponent>()->SetCharacterUpDirection(NewCharacterUpDirection);
}
void AGSCharacter::PawnClientRestart()
{
Super::PawnClientRestart();
// Make sure that we have a valid PlayerController.
if (APlayerController* PC = Cast<APlayerController>(GetController()))
{
// Get the Enhanced Input Local Player Subsystem from the Local Player related to our Player Controller.
if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PC->GetLocalPlayer()))
{
// PawnClientRestart can run more than once in an Actor's lifetime, so start by clearing out any leftover mappings.
Subsystem->ClearAllMappings();
// Add each mapping context, along with their priority values. Higher values outprioritize lower values.
Subsystem->AddMappingContext(DefaultMappingContext, 0);
}
}
}

View File

@ -13,14 +13,6 @@ class AGSCharacter : public ACharacter
{
GENERATED_BODY()
/** Camera boom positioning the camera behind the character */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class USpringArmComponent* CameraBoom;
/** Follow camera */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class UCameraComponent* FollowCamera;
/** MappingContext */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputMappingContext* DefaultMappingContext;
@ -45,17 +37,14 @@ protected:
/** Called when the player changes the gravity direction */
void ChangeGravityDirection(const FInputActionValue& Value);
public:
virtual void PawnClientRestart() override;
protected:
// APawn interface
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
// To add mapping context
virtual void BeginPlay();
public:
/** Returns CameraBoom subobject **/
FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; }
/** Returns FollowCamera subobject **/
FORCEINLINE class UCameraComponent* GetFollowCamera() const { return FollowCamera; }
};

View File

@ -15,8 +15,7 @@ AGSGameModeBase::AGSGameModeBase()
TimeBetweenRounds = 20.0f;
RoundTime = 600.0f;
WarmupTime = 15.0f;
bWarmupEnabled = true;
bDelayedStart = bWarmupEnabled;
bDelayedStart = true;
PlayerControllerClass = AGSPlayerController::StaticClass();
PlayerStateClass = AGSPlayerState::StaticClass();
@ -253,7 +252,7 @@ void AGSGameModeBase::HandleMatchIsWaitingToStart()
AGSGameState* GS = GetGameState<AGSGameState>();
if(GS && GS->GetRemainingTime() <= 0)
{
if(bWarmupEnabled)
if(bDelayedStart)
{
GS->SetRemainingTime(WarmupTime);
}

View File

@ -117,11 +117,7 @@ protected:
// duration of the pre-match/warmup period, in seconds
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category=Settings, meta = (ClampMin = 0))
float WarmupTime;;
// whether or not there is a warmup or the round should immediately start
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category=Settings)
bool bWarmupEnabled;
float WarmupTime;
FTimerHandle TimerHandle_DefaultTimer;
};

View File

@ -4,6 +4,8 @@
void AGSPlayerController::Client_GameStarted_Implementation()
{
FInputModeGameOnly GameOnly;
SetInputMode(GameOnly);
SetIgnoreMoveInput(false);
// enable all actions on pawn