Hello, I’m running into a weird issue where sometimes the client’s player controller is not possessing the character. Each time I run it one of 3 things happens:
- The client’s player controller successfully possesses the character (good)
- The client’s player controller never possesses the character (bad)
- The client’s player controller eventually (after about 5-10 seconds) possesses the player character (bad)
I’m not sure what I’m doing wrong but I’ll try to explain my current setup as best as I can…
- I’m using GameState and GameMode (not
GameStateBase or GameModeBase) - In the Project Settings I have specified my
Default Pawn Class and my Player
Controller Class (I’m not overriding
the game mode in world settings
either) - In the level I have two PlayerStart objects, 1 for my server
and 1 for the client (both with
default values) - I didn’t change any
replication settings in my Character
or Player Controller classes so by
default, the Character has Replicated
set to true and the Player Controller
has it set to false
Other than that I’m not doing anything that I imagine has any affect on it. One thing to note is that in my PlayerController class I’ve overridden the virtual void SetPawn(APawn* InPawn) override;
function like so:
void AMyPlayerController::SetPawn(APawn* InPawn)
{
Super::SetPawn(InPawn);
}
Just to see when/if the pawn gets set. As you might guess, when the controller fails to possess the character, InPawn is null. And in the event where it successfully possesses the character, InPawn is valid. So something is causing SetPawn
to be called with null instead of the valid pawn. The callstack just says “External Code” so I’m not sure what is calling this.
Any suggestions would be greatly appreciated!!!