Setup input mapping in player controller
This commit is contained in:
parent
e38379586c
commit
f31f0437e9
@ -5,16 +5,32 @@
|
|||||||
// FF includes
|
// FF includes
|
||||||
#include "FFInputBufferComponent.h"
|
#include "FFInputBufferComponent.h"
|
||||||
|
|
||||||
|
// UE includes
|
||||||
|
#include "EnhancedInputSubsystems.h"
|
||||||
|
|
||||||
AFFPlayerController::AFFPlayerController()
|
AFFPlayerController::AFFPlayerController()
|
||||||
{
|
{
|
||||||
InputBuffer = CreateDefaultSubobject<UFFInputBufferComponent>(TEXT("InputBuffer"));
|
InputBuffer = CreateDefaultSubobject<UFFInputBufferComponent>(TEXT("InputBuffer"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AFFPlayerController::SendInputsToRemote() const
|
void AFFPlayerController::SendInputsToRemote() const
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AFFPlayerController::SetupInputComponent()
|
void AFFPlayerController::SetupInputComponent()
|
||||||
{
|
{
|
||||||
Super::SetupInputComponent();
|
Super::SetupInputComponent();
|
||||||
|
|
||||||
|
if (ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(Player))
|
||||||
|
{
|
||||||
|
if (UEnhancedInputLocalPlayerSubsystem* InputSystem = LocalPlayer->GetSubsystem<UEnhancedInputLocalPlayerSubsystem>())
|
||||||
|
{
|
||||||
|
if (!DefaultInputMapping.IsNull())
|
||||||
|
{
|
||||||
|
InputSystem->AddMappingContext(DefaultInputMapping.LoadSynchronous(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,13 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
// FF includes
|
||||||
|
#include "FFInputBufferComponent.h"
|
||||||
|
|
||||||
// UE includes
|
// UE includes
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "GameFramework/PlayerController.h"
|
#include "GameFramework/PlayerController.h"
|
||||||
|
#include "InputMappingContext.h"
|
||||||
|
|
||||||
#include "FFPlayerController.generated.h"
|
#include "FFPlayerController.generated.h"
|
||||||
|
|
||||||
@ -23,7 +27,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Sends all unacknowledged inputs to the remote
|
* Sends all unacknowledged inputs to the remote
|
||||||
*/
|
*/
|
||||||
void SendInputsToRemote() const;
|
virtual void SendInputsToRemote() const;
|
||||||
|
|
||||||
// APlayerController interface
|
// APlayerController interface
|
||||||
virtual void SetupInputComponent() override;
|
virtual void SetupInputComponent() override;
|
||||||
@ -32,7 +36,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
/** MappingContext */
|
/** MappingContext */
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "UFF|Input", meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "UFF|Input", meta = (AllowPrivateAccess = "true"))
|
||||||
class UInputMappingContext* DefaultMappingContext;
|
TSoftObjectPtr<UInputMappingContext> DefaultInputMapping;
|
||||||
|
|
||||||
/** Input Buffer component */
|
/** Input Buffer component */
|
||||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "UFF|Input", meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "UFF|Input", meta = (AllowPrivateAccess = "true"))
|
||||||
|
Loading…
Reference in New Issue
Block a user