Set Actor Location on client / replication

Hey there, I have a blueprint actor and set replicate and replicate movement to true but when I use “Set Actor Location” with the client the object only changes location in the clients window. At the server window the object remains at it’s original position.
Any idea what might went wrong?

It does! Thank you for the explanation :slight_smile:

Everything that is replicated and what you want on every client/server, needs to be set by the server.
So if you let the client Set an Actor location you need to call a custom Replicated event that is “RunOnServer” and got an Input of the VectorLocation and the Actor you want to set. So the Blue Custom Event Call node of your new replicated event will get the Vektor and the Actor as input and the red one that will be run on the server will have these two as outputs to actually set the actors postion.

Here is a picture:

http://puu.sh/aEble/9b21fbdde9.png

For the actor you can use the one you want to change (i used the actor i run it on (self) for this) and the Vector in the blue node can be set to what ever is on your mind. I left it empty at this point.

These two variables will be passed to the Red node that is run on the server and, like you can see on the screen, will change its location.

(: Hope that works for you mate

this is good, but dosnt work well with physical objects, like my physics thruster driven space ship, help?

Well, Physics are always kinda special. I learned (although i don’t actually know if that’s still the case), that Physics should always be calculated on the Server and THEN send back to the Clients. The Clients themselves should NOT calculate physics. So the Client only has the Thruster animation, but doesn’t actually move the ship.

The only downside to this is the Player who wants to move the Ship, since he would need to wait for the Server to give him the correct position. So you would want to apply physics on the Server and the LOCAL Player. But every other Client will only see the position of the Player updating.

So every player calculates physics for his own ship. The Server ALSO calculates the physics for that ship and the replication of the position takes care of correcting things that might went wrong on the Client side. And all other clients that only have a replicated copy of the ship, they only apply the location they get.

I was running into a similar issue, even using a run-on-server RPC function. The problem in my case turned out to be the “net load on client” flag under replication on the actor itself; it should be OFF.

I think what’s going on here is net load on client basically tells connecting clients to load all objects in the level during client connection from the client’s hard drive; I think it does this to save bandwidth by not having to send all the information about the level. So if your actor is already in the level (which mine was) and you are trying to move it after the fact during level or game mode BeginPlay or similar, you want the client to get information about the actor directly from the server when loading the map, instead of loading the initial start locations from the map it already has (which is normally safe for objects that won’t need to move, hence the default to “net load on client” being sane)

I also checked “replicate movement” but i’m not sure if that was necessary. If your actor exists in the level itself at load, I think this should fix your issue.

Thank you very much Dave Sullivan. That is exactly what I needed. I was buggering about trying to ‘force network update’ and all sorts of stuff - and all I needed was to untick a box or two.
I shall mark this in my diary and call it ‘Dave Sullivan day’ and I will drink to your health.

1 Like

ty. Years later you have saved me

How do you replicate the movement on the client as well? My movement on my dedicated server is super jumpy, probably because my client is contantly waiting for the update in location from the server.

How would I let my client also move and change its own location and then get corrected if needed?

This image does not opens up.