Download

[SOLVED] Second Player is not functioning the same as the first player?

Hey all,

I’m playing around with getting a simple multiplayer game working so I can learn replication. I’ve tweaked the first person player character slightly with some impulse on the Z axis to act as a jet pack but for some reason when I test this in multiplayer by setting the number of players to 2, the first player can jet pack around and the second player can see them doing so (which makes me think the replication is working fine) but the second player can only walk around and can’t jet pack for some reason. I’m not sure if this has something to do with inputs or if the code isn’t working.

Here’s my code:

Player Character:

Game Mode:

Any help would be appreciated.

@TorQueMoD

Just an educated guess… But the player with everything working may be running as a Listen-Server (a Dedicated-Server with Player attached). Whereas the second player with nothing working, is actually the ‘real’ client. Players running on a listen-server tend to experience everything working as if its Local Split-Screen Multiplayer etc…

Second aspect - Physics… Your jetpack test might seem like a logical starting point. But its actually the worst kind of test starting out. UE4 is a non-deterministic physics engine. That means on all ‘real’ clients (non-listen-server) the outcome of that Impulse isn’t reliable. Its possible every client will experience a different outcome from what is seen on the server etc.

Perhaps focus instead on leveraging the CMC and its built-in replication… And / Or read physics sync’ing / replication / rewind threads by TheJamsh / Rama etc…

@TorQueMoD

Just an educated guess… But the player with everything working is running as a Listen-Server (a Dedicated-Server with Player attached). Whereas the second player with nothing working, is actually the ‘real’ client. Players running on a listen-server will tend to experience everything working correctly (as if its Local Split-Screen Multiplayer etc).

Physics… Your jetpack test might seem like a logical starting point. But its actually the worst kind of test starting out. UE4 is a non-deterministic physics engine. That means on all ‘real’ clients (non-listen-server), the outcome of that Impulse isn’t very reliable. Its possible every client will experience a different outcome from what is seen on the server etc.

Perhaps focus instead on leveraging the CMC and its built-in replication… And / Or read physics sync’ing / replication / rewind threads by TheJamsh / Rama etc…

Hey Franktech thanks for the reply. Well, firstly I’m just using the PIE mode for my test so I don’t know who is the listen and who is the client. Secondly, even if the jetpack is a terrible idea for the first test (I thought movement was replicated automatically but I guess adding impulse to the movement doesn’t count?) the second player should still be able to do it shouldn’t they? The issue should be that the first player won’t be able to see them doing it because the replication isn’t synchronizing the event? At least that’s how I thought it worked.

In my case, while switching over to the second player’s screen, I can walk around without issue, but pressing the Jump button does nothing. It’s like it’s not even coded in for them. Maybe I should add in a print screen node to see if the jump is even executing.

@TorQueMoD

Definitely, add some Print Strings and include some of the server nodes too (Switch / Has Authority / IsServer etc)
Also do a test running Standalone and see if you get the same result as PIE along with tick / untick single-process…

Conventional CMC walk-forward / perform anim is replicated but as regards bolting-on-physics, I believe this applies…

@TorQueMoD

Definitely, add some Print-Strings and include some of the Server nodes too (Switch / Has-Authority / IsServer etc)
Also do a test running Standalone and see if you get the same result as PIE, along with tick / untick ‘single-process’…

Conventional CMC walk-forward / perform anim is replicated but as regards bolting-on-physics, I believe this applies…

Thanks again for the help. I’ll post back if I get it working or if I need more help.

Ok so it is indeed activating the impulse across the network and I was able to get it working by replicating the custom events for Jump Pressed and Jump Released. Thanks so much for the help!

Ok so it is indeed activating the impulse across the network as I found with the print string and I was able to get it working by replicating the custom events for Jump Pressed and Jump Released. Now my problem is that it’s not smooth. I set the replication to be on the server and reliable but there’s a ton of “lag” when you watch the players “jetting”. Any ideas on how to smooth this out?

Here’s a video showcasing the “lag”
https://youtube.com/watch?v=lMuFhLZ77Jo

At first I thought this was because I switched from using Event Tick for the impulse to using an Event Timer (for better performance) but switching back to Event Tick didn’t make a difference.

@TorQueMoD

Try to follow / get ideas from some of the sample threads linked here.
That’s about the limit of my own understanding on this area right now!

Ok thanks!