Hello everyone,
I’m currently working on a multiplayer project in Unreal Engine, where a client should be able to move a physics-based actor (a pawn with physics simulation enabled). While the setup works perfectly on the server, the client’s movements are not replicating properly to the server or other clients. Here’s a detailed breakdown of the issue:
Setup:
- Actor Setup:
- The actor is a
Pawn
. - Root Component:
StaticMeshComponent
withSimulate Physics
set to True. - Replicates and Replicate Movement are both enabled for the actor.
- Replication Settings:
- The actor is set to replicate correctly:
Replicates
: TrueReplicate Movement
: True
- Physics Replication Mode is set to
Default
.
- Input:
- I’m using Enhanced Input Actions for player movement.
- Client inputs are processed, and a
Run on Server
RPC is used to send the movement request to the server.
- Server-Side Processing:
- The server processes the movement by applying forces (using
Add Force
orAdd Torque
) to theStaticMeshComponent
. - After processing, a Multicast RPC is used to sync the physics state to all clients.
The Problem:
- When the server moves the actor, the movement replicates to all clients correctly.
- However, when the client triggers movement (via input), the following issues occur:
- The client itself does not move (no local feedback).
- The server does not process the movement or apply forces.
- Other clients cannot see the movement triggered by the original client.
Debugging Steps Taken:
- Input Validation:
- The
Input Action
is firing correctly on the client. - The
Run on Server
RPC is also being called successfully (tested withPrint String
).
- Physics Processing:
- On the server,
Add Force
andAdd Torque
are being executed correctly. - The server-side actor moves as expected when forces are applied directly (e.g., triggered by server input).
- Replication:
- Actor replication settings (
Replicates
,Replicate Movement
) are confirmed to be enabled. - Multicast RPC is called from the server but does not seem to reach other clients.
What I’ve Tried:
- Verified that the actor has
Replicates
andReplicate Movement
enabled. - Used
Switch Has Authority
to ensure that only the server processes physics. - Tested different
Physics Replication Mode
settings (Default
,Predictive
,Interpolative
). - Added
Print String
at key points (e.g., RPC calls,Add Force
execution) to trace the flow of events. Everything seems to work on the server, but the client’s actions don’t reflect.
My Questions:
- Why is the client’s input not causing the actor to move locally or on the server?
- How can I properly replicate client-side physics movement to the server and other clients?
- Am I missing something critical in terms of replication or physics setup for multiplayer?
Any advice, solutions, or debugging tips would be greatly appreciated! If you need further details or screenshots of my Blueprint setup, feel free to ask.
Thank you in advance!