HI,
I’m new to UE4 and trying to get a basic Twin Stick multiplayer game working. Using only 1 client works great. However, when trying to test with 2 clients, Visual Studio breaks when accessing Player due to an access violation.
bool APlayerController::GetMousePosition(float& LocationX, float& LocationY) const
{
bool bGotMousePosition = false;
ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(Player); // crashes here as it can't access Player
if (LocalPlayer)
{
FVector2D MousePosition;
bGotMousePosition = LocalPlayer->ViewportClient->GetMousePosition(MousePosition);
if (bGotMousePosition)
{
LocationX = MousePosition.X;
LocationY = MousePosition.Y;
}
}
return bGotMousePosition;
}
My current setup is that each player is a Pawn, which is what I’d like to replicate… but I can’t figure out why Player and wouldn’t be accessible with multiple clients.
I’ve read the networking, pawn and controller docs and looked at a number of questions, but haven’t managed to figure out the proper logic. Any help would be greatly appreciated.
Thanks