Why doesn't SetLocation and SetRotation work on replicated actors?

Hey guys,

So I have the following function implementation in my AShip class, which inherits from APawn.

void AShip::OnRep_ShipRemotePhysicsState()
{
// doesn't work.
	TeleportTo(ShipRemotePhysicsState.Location, ShipRemotePhysicsState.Rotation, false, true);

// doesn't work.
	/*SetActorLocation(ShipRemotePhysicsState.Location);
	SetActorRotation(ShipRemotePhysicsState.Rotation);*/
// does work.
	//MeshComponent->SetPhysicsLinearVelocity(ShipRemotePhysicsState.LinearVelocity);
	//MeshComponent->SetPhysicsAngularVelocity(ShipRemotePhysicsState.AngularVelocity);
}

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.

Any ideas?

EDIT: The latest post in my thread on networking movement data has additional information on my intent / implementation. I thought I’d only describe the core of the problem here to aid in problem solving. Regardless, here is the post in question: [Networking] Interpolating replicated movement data in Pawn, without modifying source - C++ - Unreal Engine Forums

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.

bump, I’m having the same issue as well.

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.

Still having this problem in February 2015 (4.7 Preview 5)

Same thing here on 4.7.6
I’m guessing this is intended behaviour? Not sure why though. I guess moving the root component will have to do.

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!

Bump! Having the same issue in 4.10.2