I’ve been trying to set the actor location and rotation directly upon receiving the data from the server (in this case, the data is sent to all non-owning clients, for the purposes of moving around the other actors in the world that a client would see, apart from their own).
For some reason, when using only SetLocation/SetRotation and/or TeleportTo, the remote actors don’t seem to move, however if I set the physics data on my root component (MeshComponent), they do move. This is an issue, however, as I want the replicated data for pure location / rotation to override the client’s version where needed - the clients should not at all be using a velocity (I am doing this as a test).
Basically, the server sends the location and rotation to all clients not owning this particular AShip, and they should set their replicated copy’s position and rotation to the supplied values. This does not at all work - all clients see 0 movement (both location and rotation) for all other actors.
Just bumping this - it seems that this is some undesired behaviour.
With a USkeletalMeshComponent as my root, SetActorLocation and SetActorRotation both don’t work. This is also true on the server - when I execute my client->server RPC, which passes through new physics data, using these two functions on the server-side results in no change. So I must ask;
How the hell do I place my actors at specified positions? Why can’t I use SetActorLocation ever?
EDIT: SetLocation has been returning true, so it does work, in that sense.
Make sure that the object you’re trying to move has simulate physics disabled - you can’t use these set locations on a simulating actor (same deal as Unity). Try ->SetAllPhysicsLocation(…) and SetAllPhysicsRotation(…) or similar.
Actually I have managed to get this working. In my current setup I have a pawn which is replicated. I do my own custom movement updates via a custom movement component, that tracks where the pawn SHOULD be according to the server and then moves from it’s current location towards that spot.
The pawn Tick function that I have was updating some of the movement parameters (including in the simulated proxies). I got rid of that by using
if (Role != ROLE_AutonomousProxy) // then we are not originating any movement
{
return;
}
At the start of the pawn tick function, and now SetActorLocation works fine. I also have
bReplicateMovement = false; // we will handle our own movement
In my pawn constructor.
I guess what I’m saying is that I got it to work, so it is possible. Hope this helps!