@@ -298,7 +298,6 @@ public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReade
298
298
private int m_LastSentTick ;
299
299
private NetworkTransformState m_LastSentState ;
300
300
301
-
302
301
/// <summary>
303
302
/// Tries updating the server authoritative transform, only if allowed.
304
303
/// If this called server side, this will commit directly.
@@ -396,7 +395,7 @@ internal bool ApplyTransformToNetworkState(ref NetworkTransformState networkStat
396
395
{
397
396
var position = InLocalSpace ? transformToUse . localPosition : transformToUse . position ;
398
397
var rotAngles = InLocalSpace ? transformToUse . localEulerAngles : transformToUse . eulerAngles ;
399
- var scale = InLocalSpace ? transformToUse . localScale : transformToUse . lossyScale ;
398
+ var scale = transformToUse . localScale ;
400
399
return ApplyTransformToNetworkStateWithInfo ( ref networkState , dirtyTime , position , rotAngles , scale ) ;
401
400
}
402
401
@@ -510,7 +509,7 @@ private void ApplyInterpolatedNetworkStateToTransform(NetworkTransformState netw
510
509
511
510
// todo: we should store network state w/ quats vs. euler angles
512
511
var interpolatedRotAngles = InLocalSpace ? transformToUpdate . localEulerAngles : transformToUpdate . eulerAngles ;
513
- var interpolatedScale = InLocalSpace ? transformToUpdate . localScale : transformToUpdate . lossyScale ;
512
+ var interpolatedScale = transformToUpdate . localScale ;
514
513
515
514
// InLocalSpace Read
516
515
InLocalSpace = networkState . InLocalSpace ;
@@ -599,18 +598,7 @@ private void ApplyInterpolatedNetworkStateToTransform(NetworkTransformState netw
599
598
// Scale Apply
600
599
if ( SyncScaleX || SyncScaleY || SyncScaleZ )
601
600
{
602
- if ( InLocalSpace )
603
- {
604
- transformToUpdate . localScale = interpolatedScale ;
605
- }
606
- else
607
- {
608
- transformToUpdate . localScale = Vector3 . one ;
609
- var lossyScale = transformToUpdate . lossyScale ;
610
- // todo this conversion is messing with interpolation. local scale interpolates fine, lossy scale is jittery. must investigate. MTT-1208
611
- transformToUpdate . localScale = new Vector3 ( interpolatedScale . x / lossyScale . x , interpolatedScale . y / lossyScale . y , interpolatedScale . z / lossyScale . z ) ;
612
- }
613
-
601
+ transformToUpdate . localScale = interpolatedScale ;
614
602
m_PrevNetworkState . Scale = interpolatedScale ;
615
603
}
616
604
}
@@ -679,8 +667,6 @@ private void OnNetworkStateChanged(NetworkTransformState oldState, NetworkTransf
679
667
680
668
private void Awake ( )
681
669
{
682
- m_Transform = transform ;
683
-
684
670
// we only want to create our interpolators during Awake so that, when pooled, we do not create tons
685
671
// of gc thrash each time objects wink out and are re-used
686
672
m_PositionXInterpolator = new BufferedLinearInterpolatorFloat ( ) ;
@@ -704,6 +690,10 @@ private void Awake()
704
690
705
691
public override void OnNetworkSpawn ( )
706
692
{
693
+ // must set up m_Transform in OnNetworkSpawn because it's possible an object spawns but is disabled
694
+ // and thus awake won't be called.
695
+ // TODO: investigate further on not sending data for something that is not enabled
696
+ m_Transform = transform ;
707
697
m_ReplicatedNetworkState . OnValueChanged += OnNetworkStateChanged ;
708
698
709
699
CanCommitToTransform = IsServer ;
@@ -863,6 +853,8 @@ protected virtual void Update()
863
853
var oldStateDirtyInfo = ApplyTransformToNetworkStateWithInfo ( ref m_PrevNetworkState , 0 , m_Transform ) ;
864
854
865
855
// there are several bugs in this code, as we the message is dumped out under odd circumstances
856
+ // For Matt, it would trigger when an object's rotation was perturbed by colliding with another
857
+ // object vs. explicitly rotating it
866
858
if ( oldStateDirtyInfo . isPositionDirty || oldStateDirtyInfo . isScaleDirty || ( oldStateDirtyInfo . isRotationDirty && SyncRotAngleX && SyncRotAngleY && SyncRotAngleZ ) )
867
859
{
868
860
// ignoring rotation dirty since quaternions will mess with euler angles, making this impossible to determine if the change to a single axis comes
0 commit comments