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