Skip to content
Snippets Groups Projects
Commit 75b578ca authored by David Gilbert's avatar David Gilbert :bug:
Browse files

fix(replication): Makes ClientTransformReplication use relative position and rotation.

parent b82a2022
No related branches found
No related tags found
2 merge requests!120Draft: UE5.4-2024.1,!113Pull dev/5.4 changes into dev/5.5
Pipeline #554930 passed
...@@ -26,8 +26,8 @@ void UClientTransformReplication::UpdateState(float DeltaTime) ...@@ -26,8 +26,8 @@ void UClientTransformReplication::UpdateState(float DeltaTime)
// Only do this if we actually replicate the actor // Only do this if we actually replicate the actor
if (GetIsReplicated()) if (GetIsReplicated())
{ {
const FVector Loc = OwningActor->GetActorLocation(); const FVector Loc = OwningActor->GetRootComponent()->GetRelativeLocation();
const FRotator Rot = OwningActor->GetActorRotation(); const FRotator Rot = OwningActor->GetRootComponent()->GetRelativeRotation();
// Only update state if the local state changed // Only update state if the local state changed
if (!Loc.Equals(ReplicatedTransform.Position) || !Rot.Equals(ReplicatedTransform.Rotation)) if (!Loc.Equals(ReplicatedTransform.Position) || !Rot.Equals(ReplicatedTransform.Rotation))
......
...@@ -56,7 +56,10 @@ protected: ...@@ -56,7 +56,10 @@ protected:
// For now, directly apply the transforms: // For now, directly apply the transforms:
auto* OwningActor = GetOwner(); auto* OwningActor = GetOwner();
if (OwningActor && OwningActor->HasValidRootComponent()) if (OwningActor && OwningActor->HasValidRootComponent())
OwningActor->SetActorLocationAndRotation(ReplicatedTransform.Position, ReplicatedTransform.Rotation); {
OwningActor->SetActorRelativeLocation(ReplicatedTransform.Position);
OwningActor->SetActorRelativeRotation(ReplicatedTransform.Rotation);
}
} }
// Unreliable Server RPC that sends the transform from owning client to the server // Unreliable Server RPC that sends the transform from owning client to the server
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment