Hey guys,
So in my networking research, I started to encounter problems determining if a pawn was currently locally controlled or not. I have reduced the problem to a simple repro;
-
Create a blank project in 4.3.0.
-
Add a new code class that inherits from APawn.
-
Override the BeginPlay method, and add the code from below this list.
-
Add bReplicates = true; to the constructor.
-
Create a new gamemode (in blueprints), and then select your new class as the default pawn.
-
Run the game in the editor with 1 client connected to a dedicated server.
-
Observe that the ‘Not locally controlled’ message appears twice, despite the pawn being controlled locally by the client.
if (IsLocallyControlled())
{
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Green, TEXT(“Ship is locally controlled!”));
}
else if (!IsLocallyControlled())
{
GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Blue, TEXT(“Ship is not locally controlled!”));
}
Any insight would be appreciated.
Thanks.