Hello,
I’m having trouble getting a simple client/server RunOnServer call working my project. But what’s odd is, I’ve done this in tutorials from brand new projects and it works very easily with little effort. I think there’s something wrong with the way my project is set up. Possibly related to my Pawn, or Level, actor ownership, or project settings. Can you please take a look and share some insight as to what I might be missing?
Background
- I made a working proof of concept for a game and now I’m adding multiplayer functionality.
- I can easily get client/server calls working in tutorial projects but for some reason not this project.
- Unreal version 5.4
- I don’t see any networking errors or warnings in the logs.
- I’m using Switch Has Authority where needed (I think)
- I have replication enabled on the Blueprint in which I’m working (BP_Board). For some reason it’s owner was none so I tried setting it manually but that didn’t fix the issue. But this may be related?
- I’ve set RunOnServer exactly as seen in the tutorial
- I’ve tried Multicast (instead of RunOnServer) and it seems that the other clients are receiving the event! But the Server is still not receiving the event. No idea how that’s possible because isn’t the server relaying the message to the other clients???
- I’ve tried NetMode Play as Client with dedicated server, and Listen Server. I get the same problem on both
- I’ve tried with only 1 client, 2 clients, etc. Same result.
One big difference I noticed from my project vs the tutorial that might be the problem: In my project, I’m setting my DefaultPawn in Project settings Maps & Modes to None. And then I’m creating my Pawn for Player0 and Pawn for Player1 inside my level. Each Pawn contains a camera. And I’m using Auto Possess Player to assign them to Player 0 and Player 1 respectively. Is that a good way to do it? Is my Player Pawn setup possibly to blame for why this isn’t working? See screenshots below.
Another difference between my project and tutorial: Owner of BP_Board was set to None/Null. So for some reason I had to Set the owner manually. But that still didn’t fix the issue. I wonder if somehow the server doesn’t see that the player owns BP_Board so it’s not replicating it. But I’m not sure how to fix that. Note: I Created BP_Board in the level, I did not spawn it dynamically. Idk if that matters. See screenshots below.
Another difference, in my project I’m making RunOnServer call within BP_Board, which is an actor I added to my level. Where as in the tutorial they are making RunOnServer calls in their Pawn (BP_ThirdPersonCharacter). Does that matter? I would assume I should be able to make client/server calls on any BP as long as ownership is set up correctly. That’s why I’m wondering if this is an ownership problem. But I’m not sure how to investigate this further…
My client event where the client presses F on keyboard
My server event, Run on Server Replication enabled. ROS_Test
My BP_Board blueprint class where these events exist, Replication is turned on in class defaults
Project Settings, Maps & Modes
Where I initialized BP_PlayerPawn0 in level
Where I initialized BP_PlayerPawn1 in level
I noticed BP_Board owner was null, so I set it manually here
BP_Board client & server running. Note I only had 1 client running in this test.
GM running on server
PlayerPawns running on client & server.
Logs from this test. You can clearly see things are getting initialized in OnBeginPlay. The client presses F, I can see the player controller is the owner of BP_Board, I’m calling the function on the server, but the server never receives the event!
LogBlueprintUserMessages: [None] Client initializing BP_PlayerPawn
LogBlueprintUserMessages: [None] Client initializing BP_PlayerPawn
LogBlueprintUserMessages: [None] Client initializing BP_Board
LogBlueprintUserMessages: [None] Client Pressed F
LogBlueprintUserMessages: [None] Owner = BP_PlayerController_C_0
LogBlueprintUserMessages: [None] Client: Before calling ROS_Test
LogBlueprintUserMessages: [None] I am client calling ROS_Test
If this was working I would see Server: ROS_Test. I should see this!
. But I do not…
And finally, just a quick screenshot from the tutorial I was following, I was able to get this working without any issues. And aside from the differences mentioned above, doing this same thing doesn’t seem to work for me in my project