Hi
Everything works fine for the host, but not for the client, because in Unreal Engine the host is both the server and a client at the same time. So when the host changes the movement mode, it’s directly done on the server, and it works.
But a client is a separate machine that doesn’t have the authority to directly modify server-side logic. So when the client tries to change the movement mode, the server doesn’t know about it — and nothing happens.
To fix this, you need to make sure that the client sends a request to the server, and the server handles the actual change of movement mode.
Here’s what to do:
- Create a Custom Event in your
BP_PlayerCharacter
that is set to Run on Server.
- In the event settings, enable Replicates → Run on Server.
- For example, name it
SetFlyMode_Server
.
- Inside
SetFlyMode_Server
, implement the logic that sets the movement mode (e.g.,Set Movement Mode
toFlying
). - If you already have an event like
SetFlyMode
that is being called on the client (e.g., on key press), you should modify it to callSetFlyMode_Server
instead.
Important: The server should not call the client to change movement. Instead, the client must ask the server to make the change. That’s likely where the problem in your current setup is.
Additionally, I noticed you’re using the Get Player Pawn
node with Player Index = 0. This can cause issues in multiplayer. Each client has a different index, and index 0 usually refers to the server/host. So when multiple players are connected, this reference may not work as expected.
Recommended approach:
- Use
PlayerState
to get theControlled Pawn
. - Then cast it to your character class.
- From there, access
Character Movement
and perform your logic.
This method avoids index-related issues and makes your system more stable in a multiplayer environment.