Hey !
Yes, that was indeed my first try: using playercontrollers and differentiating them with the help of ROLE_Authority combined with those functions you are refering to (IsLocalController() and IsLocalPlayerController()).
But this time i get the inverse problem that i got with the gamestate, the funtion are called only on the first PC, so they are all marked “first PC” or “Local PC”, i can only differentiate server from client, but can never reach the non localcontroller).
For example, with this code in the PC BeginPlayState() function:
if (Role == ROLE_Authority)
{
GEngine->AddOnScreenDebugMessage(-1, 100.f, FColor::Cyan, TEXT("Server"));
}
else
{
GEngine->AddOnScreenDebugMessage(-1, 100.f, FColor::Cyan, TEXT("Client"));
}
if (IsLocalPlayerController())
{
GEngine->AddOnScreenDebugMessage(-1, 100.f, FColor::Cyan, TEXT("Local PC"));
}
else
{
GEngine->AddOnScreenDebugMessage(-1, 100.f, FColor::Cyan, TEXT("not local PC"));
}
if (this == GetWorld()->GetFirstPlayerController())
{
GEngine->AddOnScreenDebugMessage(-1, 100.f, FColor::Cyan, TEXT("first PC"));
}
else
{
GEngine->AddOnScreenDebugMessage(-1, 100.f, FColor::Cyan, TEXT("not first PC"));
}
I was expecting to get as many messages on each game instance as players connected (for exemple with 4 clients, i was expecting 5 messages on the server and 5 on each client). But i got only one message per machine. I remade the test quickly to get 2 screenshots (one message per machine, whatever the number of players: this the BeginPlayState() function is only called on the first player controller):
So technically, although i don’t understand what’s going on, i can use that for my purpose, and i did at first, but then i thought the file server should be attached to the gamestate and not to the players, as there is only one gamestate per computer but several PC’s, and moreover the file service is more related to game mechanics than to players, which led me to that replication pb and the present thread.
So yeah, i know now 3 ways to accomplish what i want, i found one and you gave me 2 others, but as i said, none of them gives me the feeling that i fully understand what’s going on. Those “fundamental” actors, gamemode, gamestate and PC’s and how they behave and interact in a networking environment (and especially at initialization time) are very unclear to me.
For example, i can grasp the notion of replicated variables and RPC’s, but that replicated function thing (leading to a function being called twice identically on the same client), that’s a new surprise for my poor brain.
I am still experimenting (and currently struggling with multithreading), if i ever come up with an elegant (and understandable for me^^) solution, i will post it here of course.
Cheers !
Cedric