Hello ! I wanted to make my prototype multiplayer, so i tried launching it in mutliplayer playmode to see what happends, and i figured out that GetLocalPlayer was returning a nullptr in my player controller, and i can’t find why anywhere on internet… (I use this function to get the Enhanced Input Local Player Subsystem).
If you have any idea on how to fix this i’d be very happy !
void ASkirmishPlayerControllerBase::OnPossess(APawn* aPawn)
{
Super::OnPossess(aPawn);
ControlledPlayer = Cast<ASkirmishPlayerClass>(aPawn);
EnhancedInputs = Cast<UEnhancedInputComponent>(InputComponent);
if(GetLocalPlayer() != nullptr)
{
UEnhancedInputLocalPlayerSubsystem* InputSystem = GetLocalPlayer()->GetSubsystem<UEnhancedInputLocalPlayerSubsystem>();
InputSystem->ClearAllMappings();
InputSystem->AddMappingContext(PlayerMappingContext, 0);
if (IAMove)
EnhancedInputs->BindAction(IAMove, ETriggerEvent::Triggered, this,
&ASkirmishPlayerControllerBase::MovementHandling);
if (IALook)
EnhancedInputs->BindAction(IALook, ETriggerEvent::Triggered, this,
&ASkirmishPlayerControllerBase::LookingHandling);
if (IAJump)
{
EnhancedInputs->BindAction(IAJump, ETriggerEvent::Triggered, this,
&ASkirmishPlayerControllerBase::JumpTrigger);
EnhancedInputs->BindAction(IAJump, ETriggerEvent::Completed, this,
&ASkirmishPlayerControllerBase::JumpComplete);
}
if (IAGrab)
{
EnhancedInputs->BindAction(IAGrab, ETriggerEvent::Triggered, this,
&ASkirmishPlayerControllerBase::GrabObject);
EnhancedInputs->BindAction(IAGrab, ETriggerEvent::Completed, this,
&ASkirmishPlayerControllerBase::ReleaseObject);
}
}
}