Proper way to apply a constant movement to characters/objects in Multiplayer
Hello, I need the help of you guys to know how should I make (in Multiplayer) all player characters AND objects to be constantly pushed into a direction.(Somewhat like a Treadmill)
Currently, I have a 0.005 Loop Timer that AddActorWorldOffset inside each actor blueprint that I want this movement(players and objects) and that works fine, in Single Player. However, I'm afraid this method is not the right way to do it in Multiplayer, as with multiple objects doing this constantly might be too expensive on the network.
Please, I need help to do it the right way.
Thank you already!
asked Jan 31 '19 at 01:15 AM in Blueprint Scripting
If you don't need to sync all objects' movement (i.e., they are just there for aesthetics) then don't replicate them and just simulate their physics locally. However if they are important and should be synced across all players, then try to minimize their number as possible. There's is no easy way to answer how many objects can you replicate, you just have to test them yourself.
Also, aside from Character class where movement is smoothly replicated, you have to implement a similar way to interpolate the objects' movement from one replication update to another. Without it, they'll appear jittery or at worst, teleports from one spot to the next every replication update (because not all objects are replicated every tick).
Here's a bit more info about how CharacterMovementComponent handles the syncing of player movement in a network environment.
answered Jan 31 '19 at 02:13 PM
When you're talking network movement of actors, you need to read up on dead reckoning (not the game, the process of predicting movement).
In a nutshell, clients send simple commands like move forward, stop moving forward, turn left, stop turning left, etc. The server will always update players based on what actions they last knew they were performing. Based on time, the server can calculate the player's current location, rotation, etc. based on that data.
As a client is running, you smoothly update their position, locations, etc. based on their input, send that data to the server, which will use dead reckoning to figure out where the player is at any time, and periodically send updates to the client to sync up. The client will then interpolate from it's last known local position to the server's updated position. That's why you see the "rubber banding" of your players bouncing around in other games - it's lost sync with the server and the server is forcing the client to sync back to it's last known position.
The interpolating is the smooth motion you are referring to. You don't know it's doing it, but it is. Periodically, it moves from the last known position the client thinks it has to the position the server told it that it really is. You can use a vinterpt to and rinterpto over the update rate period of time between these server to client updates.
So, if a client sends a move forward command, the server will continuously move a client forward based on the elapsed time until it receives a stop moving forward command from the client.
answered Feb 07 '19 at 05:49 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here