Hi! I am trying to digest and undestand how multiplayer works but I was struggling for days and still cant get it even watching videos on YT, etc.
I did this test: two Pawn cubes that are controlled with mouse and keyboard.
there is a boolean inside that changes the control type from physics control (the cube is moved by forces) and non physics (just adding rotation and location offset to the cube).
I added 2 player start in the scene as defaul pawn my pawn class
sometimes the client just dont spawn…idk why…just black screen.
I am running PIE windows, 2 players and as listener server
so first problem is erratic black screen on client only player and must retry playing.
also in client window, both players are in random places and not where player start
actors are placed. Floor is cosmetic (no collisions)
using physics control or non physics causes same problems.
client transforms are not being updated in the server side.
here is the project in case someone wants to see if can help.
Its UE 5.2
hey @L1z4rD89 Thanks a lot for your simple and clear example!
In this example is very clear how to move the cubes on both cases
client and server in sync.
My project is a bit more complicated because I want to move player by applying physics (by adding force and torque).
I achieved a good sync by adding the control forces from the server ( all players
will replicate what server moves) but in server side things jitter ( its understandable).
for tackiling that last issue, I duplicated the visuals (meshes) and I just show actual visuals
on the server player (because there is not jitter) and in the clients I am showing the duplicated meshes that dont have physics because are just visuals and update transforms with Interp. Works like a charm.
The final step to make it all work is transfer input controls from the clients to the server
so server can manage the forces for all of them but I am having HUGE problems
trying to figure out hot to transfer a simple Vector2D variable from each player to the
server so Server can appy the forces to move.
This is what I am trying right now and is not working:
my actor has an enhanced input and tries to send the Vector2D movement of the left thumbstick to the server. The player sends its playerID and thumb Value
Players have an instance of Gamestate stored in gamestate variable so I dont have to cast it every time…inside the game instance I have an Array with players data. Its a truct that only holds the Vector 2D for now like this:
As I have 10 players, I already created 10 items in the gamestate ‘player data’ array and each player registers there when game begins so this array has the ten players and matches ID with array index.
I only receive a value when I move the SERVER side Actor.
When I move a client joystick there is not data displayed in gamestat
Any suggestions?
I dont want to mark this as solved even you solved a lot of clarity with your example but I am afraid if I mark as solved I wont get more replies
here I check if is owning client (actually it is because it accepts S input)
but is not working…client prints the owner name on both screens and thats it.
I tried from a new project and same results…anyway I am using unreal 5.2.1 and found various bugs before…maybe I should try in other versions or maybe this is not the solution I am looking for.
I will mark this as solved because you shared the project that clearly shows how to replicate inputs in between clients, but the core that is make communication client–>server is not solved
I found the solution. PRoblem is that the actor is not the Client owner…the real client owner is the PLAYER CONTROLLER of that actor so the call from server must be done from Player controller and not the actual actor
Anyway I really appreciate you took your time for help me out!