Skip to content

Commit f9226db

Browse files
update
work in progress. potential fix for NetworkTransform non-authority's ability to modify portions of the transform not being synchronized.
1 parent 352d63c commit f9226db

File tree

3 files changed

+484
-1
lines changed

3 files changed

+484
-1
lines changed

com.unity.netcode.gameobjects/Runtime/Components/NetworkTransform.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2524,10 +2524,25 @@ protected internal void ApplyAuthoritativeState()
25242524
// at the end of this method and assure that when not interpolating the non-authoritative side
25252525
// cannot make adjustments to any portions the transform not being synchronized.
25262526
var adjustedPosition = m_InternalCurrentPosition;
2527-
var adjustedRotation = m_InternalCurrentRotation;
2527+
var currentPosistion = GetSpaceRelativePosition();
2528+
adjustedPosition.x = SyncPositionX ? m_InternalCurrentPosition.x : currentPosistion.x;
2529+
adjustedPosition.y = SyncPositionY ? m_InternalCurrentPosition.y : currentPosistion.y;
2530+
adjustedPosition.z = SyncPositionZ ? m_InternalCurrentPosition.z : currentPosistion.z;
25282531

2532+
var adjustedRotation = m_InternalCurrentRotation;
25292533
var adjustedRotAngles = adjustedRotation.eulerAngles;
2534+
var currentRotation = GetSpaceRelativeRotation().eulerAngles;
2535+
adjustedRotAngles.x = SyncRotAngleX ? adjustedRotAngles.x : currentRotation.x;
2536+
adjustedRotAngles.y = SyncRotAngleY ? adjustedRotAngles.y : currentRotation.y;
2537+
adjustedRotAngles.z = SyncRotAngleZ ? adjustedRotAngles.z : currentRotation.z;
2538+
adjustedRotation.eulerAngles = adjustedRotAngles;
2539+
2540+
25302541
var adjustedScale = m_InternalCurrentScale;
2542+
var currentScale = GetScale();
2543+
adjustedScale.x = SyncScaleX ? adjustedScale.x : currentScale.x;
2544+
adjustedScale.y = SyncScaleY ? adjustedScale.y : currentScale.y;
2545+
adjustedScale.z = SyncScaleZ ? adjustedScale.z : currentScale.z;
25312546

25322547
// Non-Authority Preservers the authority's transform state update modes
25332548
InLocalSpace = networkState.InLocalSpace;

0 commit comments

Comments
 (0)