0
\$\begingroup\$

I've been working on a little 1V1 snipper project to try and get a better grip on the replication and the game framework of unreal engine.

So after the core gameplay, I'm trying to make a lobby system. I've been able to make the player join together without any issues, but I struggle a little bit with the replication. I'm trying to show the player's name over their pawn in the lobby, and I can't get it to work. In the client, both their name doesn't get replicated, and in the server, only the server name appear:

Client Lobby Server lobby

And I get this error from the server logs

[2020.01.21-00.45.03:318][906]PIE: Error: Only Local Player Controllers can be assigned to widgets. BP_PlayerLobbyController_C_1 is not a Local Player Controller.
[2020.01.21-00.45.03:321][906]LogScript: Warning: Accessed None trying to read property CallFunc_Create_ReturnValue
        BP_PlayerLobbyController_C /Game/Maps/Lobby.Lobby:PersistentLevel.BP_PlayerLobbyController_C_1
        Function /Game/Player/Controller/BP_PlayerLobbyController.BP_PlayerLobbyController_C:ExecuteUbergraph_BP_PlayerLobbyController:0049
[2020.01.21-00.45.03:323][906]LogScript: Warning: Script call stack:
        Function /Game/Player/Controller/BP_PlayerLobbyController.BP_PlayerLobbyController_C:ReceiveBeginPlay
        Function /Game/Player/Controller/BP_PlayerLobbyController.BP_PlayerLobbyController_C:ExecuteUbergraph_BP_PlayerLobbyController

[2020.01.21-00.45.03:325][906]LogOnlineSession: Warning: OSS: No game present to join for session (GameSession)
[2020.01.21-00.45.03:326][906]LogTemp: POST LOGIN FOR
[2020.01.21-00.45.03:331][906]LogScript: Warning: Accessed None trying to read property CallFunc_GetController_ReturnValue
        BP_Character_Lobby_C /Game/Maps/Lobby.Lobby:PersistentLevel.BP_Character_Lobby_C_1
        Function /Game/Player/Character/BP_Character_Lobby.BP_Character_Lobby_C:Display Player Name:00CC
[2020.01.21-00.45.03:333][906]LogScript: Warning: Script call stack:
        Function /Game/Player/Character/BP_Character_Lobby.BP_Character_Lobby_C:ReceiveBeginPlay
        Function /Game/Player/Character/BP_Character_Lobby.BP_Character_Lobby_C:ExecuteUbergraph_BP_Character_Lobby
        Function /Game/Player/Character/BP_Character_Lobby.BP_Character_Lobby_C:Display Player Name

[2020.01.21-00.45.03:335][906]LogScript: Warning: Accessed None
        BP_Character_Lobby_C /Game/Maps/Lobby.Lobby:PersistentLevel.BP_Character_Lobby_C_1
        Function /Game/Player/Character/BP_Character_Lobby.BP_Character_Lobby_C:Display Player Name:00E1
[2020.01.21-00.45.03:337][906]LogScript: Warning: Script call stack:
        Function /Game/Player/Character/BP_Character_Lobby.BP_Character_Lobby_C:ReceiveBeginPlay
        Function /Game/Player/Character/BP_Character_Lobby.BP_Character_Lobby_C:ExecuteUbergraph_BP_Character_Lobby
        Function /Game/Player/Character/BP_Character_Lobby.BP_Character_Lobby_C:Display Player Name

So I get that something is wrong with accessing the 2nd player controller from bluprint like this enter image description here

But I don't know how to make it work other wise. I've set the PlayerName widget to replicated, but it doesn't seem to work. enter image description here

Any idea on how I could get this to work?

\$\endgroup\$
1
\$\begingroup\$

The PlayerControllers for all players exist only on the server. Each client only has its own PlayerController, but none of the others.

Calling GetController on a pawn will only work if you're on the server or if the pawn is locally controlled. Instead, get the PlayerState from the pawn directly.

Widgets exist only on each client, they can not and should not be replicated.

\$\endgroup\$
  • \$\begingroup\$ Thanks for your answer, I somehow though it would be different because it was attach to a Widget Component! \$\endgroup\$ – Carl Boisvert Jan 28 at 0:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.