@@ -66,7 +66,7 @@ public class NetworkTransform : NetworkBehaviour
66
66
/// - The teleporting state update.
67
67
/// - When using half float precision and the `NetworkDeltaPosition` delta exceeds the maximum delta forcing the axis in
68
68
/// question to be collapsed into the core base position, this state update will be sent as reliable fragmented sequenced.
69
- ///
69
+ ///
70
70
/// In order to preserve a continual consistency of axial values when unreliable delta messaging is enabled (due to the
71
71
/// possibility of dropping packets), NetworkTransform instances will send 1 axial frame synchronization update per
72
72
/// second (only for the axis marked to synchronize are sent as reliable fragmented sequenced) as long as a delta state
@@ -104,7 +104,7 @@ public struct NetworkTransformState : INetworkSerializable
104
104
private const int k_ReliableSequenced = 0x00080000 ;
105
105
private const int k_UseUnreliableDeltas = 0x00100000 ;
106
106
private const int k_UnreliableFrameSync = 0x00200000 ;
107
- private const int k_TrackStateId = 0x10000000 ; // (Internal Debugging) When set each state update will contain a state identifier
107
+ private const int k_TrackStateId = 0x10000000 ; // (Internal Debugging) When set each state update will contain a state identifier
108
108
109
109
// Stores persistent and state relative flags
110
110
private uint m_Bitset ;
@@ -459,10 +459,11 @@ internal set
459
459
}
460
460
461
461
/// <summary>
462
- /// Returns whether this state update was a frame synchronization when
463
- /// UseUnreliableDeltas is enabled. When set, the entire transform will
462
+ /// Returns whether this state update was a frame synchronization when
463
+ /// UseUnreliableDeltas is enabled. When set, the entire transform will
464
464
/// be or has been synchronized.
465
465
/// </summary>
466
+ /// <returns><see cref="true"/> if this state update was a frame synchronization; otherwise, <see cref="false"/>.</returns>
466
467
public bool IsUnreliableFrameSync ( )
467
468
{
468
469
return UnreliableFrameSync ;
@@ -475,6 +476,7 @@ public bool IsUnreliableFrameSync()
475
476
/// <remarks>
476
477
/// Unreliable delivery will only be used if <see cref="UseUnreliableDeltas"/> is set.
477
478
/// </remarks>
479
+ /// <returns><see cref="true"/> if this state was sent with reliable delivery; otherwise, <see cref="false"/>.</returns>
478
480
public bool IsReliableStateUpdate ( )
479
481
{
480
482
return ReliableSequenced ;
@@ -586,7 +588,7 @@ public Quaternion GetRotation()
586
588
/// <remarks>
587
589
/// When there is no change in an updated state's position then there are no values to return.
588
590
/// Checking for <see cref="HasPositionChange"/> is one way to detect this.
589
- /// When used with half precision it returns the half precision delta position state update
591
+ /// When used with half precision it returns the half precision delta position state update
590
592
/// which will not be the full position.
591
593
/// To get a NettworkTransform's full position, use <see cref="GetSpaceRelativePosition(bool)"/> and
592
594
/// pass true as the parameter.
@@ -661,6 +663,8 @@ public int GetNetworkTick()
661
663
/// <summary>
662
664
/// Serializes this <see cref="NetworkTransformState"/>
663
665
/// </summary>
666
+ /// <typeparam name="T">The type of the serializer.</typeparam>
667
+ /// <param name="serializer">The serializer used for reading or writing the state.</param>
664
668
public void NetworkSerialize < T > ( BufferSerializer < T > serializer ) where T : IReaderWriter
665
669
{
666
670
// Used to calculate the LastSerializedSize value
@@ -897,7 +901,7 @@ public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReade
897
901
if ( HasScaleChange )
898
902
{
899
903
// If we are teleporting (which includes synchronizing) and the associated NetworkObject has a parent
900
- // then we want to serialize the LossyScale since NetworkObject spawn order is not guaranteed
904
+ // then we want to serialize the LossyScale since NetworkObject spawn order is not guaranteed
901
905
if ( IsTeleportingNextFrame && IsParented )
902
906
{
903
907
serializer . SerializeValue ( ref LossyScale ) ;
@@ -1419,9 +1423,8 @@ private bool ShouldSynchronizeHalfFloat(ulong targetClientId)
1419
1423
/// <remarks>
1420
1424
/// If a derived class overrides this, then make sure to invoke this base method!
1421
1425
/// </remarks>
1422
- /// <typeparam name="T"></typeparam>
1423
- /// <param name="serializer"></param>
1424
- /// <param name="targetClientId">the clientId being synchronized (both reading and writing)</param>
1426
+ /// <typeparam name="T">The type of the serializer.</typeparam>
1427
+ /// <param name="serializer">The serializer used for reading or writing the state.</param>
1425
1428
protected override void OnSynchronize < T > ( ref BufferSerializer < T > serializer )
1426
1429
{
1427
1430
m_CachedNetworkManager = NetworkManager ;
@@ -1575,11 +1578,11 @@ private void TryCommitTransform(ref Transform transformToCommit, bool synchroniz
1575
1578
Debug . LogException ( ex ) ;
1576
1579
}
1577
1580
1578
- // The below is part of assuring we only send a frame synch, when sending unreliable deltas, if
1581
+ // The below is part of assuring we only send a frame synch, when sending unreliable deltas, if
1579
1582
// we have already sent at least one unreliable delta state update. At this point in the callstack,
1580
1583
// a delta state update has just been sent in the above UpdateTransformState() call and as long as
1581
1584
// we didn't send a frame synch and we are not synchronizing then we know at least one unreliable
1582
- // delta has been sent. Under this scenario, we should start checking for this instance's alloted
1585
+ // delta has been sent. Under this scenario, we should start checking for this instance's alloted
1583
1586
// frame synch "tick slot". Once we send a frame synch, if no other deltas occur after that
1584
1587
// (i.e. the object is at rest) then we will stop sending frame synch's until the object begins
1585
1588
// moving, rotating, or scaling again.
@@ -1862,7 +1865,7 @@ private bool ApplyTransformToNetworkStateWithInfo(ref NetworkTransformState netw
1862
1865
1863
1866
networkState . NetworkDeltaPosition = m_HalfPositionState ;
1864
1867
1865
- // If ownership offset is greater or we are doing an axial synchronization then synchronize the base position
1868
+ // If ownership offset is greater or we are doing an axial synchronization then synchronize the base position
1866
1869
if ( ( m_HalfFloatTargetTickOwnership > m_CachedNetworkManager . ServerTime . Tick || isAxisSync ) && ! networkState . IsTeleportingNextFrame )
1867
1870
{
1868
1871
networkState . SynchronizeBaseHalfFloat = true ;
@@ -2056,6 +2059,10 @@ private bool ApplyTransformToNetworkStateWithInfo(ref NetworkTransformState netw
2056
2059
return isDirty ;
2057
2060
}
2058
2061
2062
+ /// <summary>
2063
+ /// Invoked whenever the transform has been updated.
2064
+ /// This method can be overridden to handle any custom logic that needs to occur after the transform has been updated.
2065
+ /// </summary>
2059
2066
protected virtual void OnTransformUpdated ( )
2060
2067
{
2061
2068
@@ -2602,6 +2609,10 @@ protected virtual void OnNetworkTransformStateUpdated(ref NetworkTransformState
2602
2609
2603
2610
}
2604
2611
2612
+ /// <summary>
2613
+ /// Invoked just before the transform state is updated.
2614
+ /// This method can be overridden to handle any custom logic that needs to occur before the transform state is updated.
2615
+ /// </summary>
2605
2616
protected virtual void OnBeforeUpdateTransformState ( )
2606
2617
{
2607
2618
@@ -2816,6 +2827,12 @@ public override void OnGainedOwnership()
2816
2827
base . OnGainedOwnership ( ) ;
2817
2828
}
2818
2829
2830
+ /// <summary>
2831
+ /// Invoked when the ownership of the <see cref="NetworkObject"/> changes.
2832
+ /// This method handles reinitialization when the local client gains or loses ownership of the <see cref="NetworkObject"/>.
2833
+ /// </summary>
2834
+ /// <param name="previous">The client ID of the previous owner.</param>
2835
+ /// <param name="current">The client ID of the new owner.</param>
2819
2836
protected override void OnOwnershipChanged ( ulong previous , ulong current )
2820
2837
{
2821
2838
// If we were the previous owner or the newly assigned owner then reinitialize
@@ -2842,7 +2859,7 @@ protected virtual void OnInitialize(ref NetworkTransformState replicatedState)
2842
2859
/// This method is only invoked by the owner
2843
2860
/// Use: OnInitialize(ref NetworkTransformState replicatedState) to be notified on all instances
2844
2861
/// </summary>
2845
- /// <param name="replicatedState"></param>
2862
+ /// <param name="replicatedState">The current <see cref="NetworkVariable{NetworkTransformState}"/> after initializing. </param>
2846
2863
protected virtual void OnInitialize ( ref NetworkVariable < NetworkTransformState > replicatedState )
2847
2864
{
2848
2865
@@ -2851,9 +2868,9 @@ protected virtual void OnInitialize(ref NetworkVariable<NetworkTransformState> r
2851
2868
private int m_HalfFloatTargetTickOwnership ;
2852
2869
2853
2870
/// <summary>
2854
- /// The internal initialzation method to allow for internal API adjustments
2871
+ /// The internal initialization method to allow for internal API adjustments
2855
2872
/// </summary>
2856
- /// <param name="isOwnershipChange"></param>
2873
+ /// <param name="isOwnershipChange">Indicates whether the initialization is due to an ownership change. </param>
2857
2874
private void InternalInitialization ( bool isOwnershipChange = false )
2858
2875
{
2859
2876
if ( ! IsSpawned )
@@ -2956,11 +2973,11 @@ public override void OnNetworkObjectParentChanged(NetworkObject parentNetworkObj
2956
2973
/// The parameters are broken up into pos / rot / scale on purpose so that the caller can perturb
2957
2974
/// just the desired one(s)
2958
2975
/// </summary>
2959
- /// <param name="posIn"></param> new position to move to. Can be null
2960
- /// <param name="rotIn"></param> new rotation to rotate to. Can be null
2976
+ /// <param name="posIn">new position to move to. Can be null.</param>
2977
+ /// <param name="rotIn">new rotation to rotate to. Can be null.</param>
2961
2978
/// <param name="scaleIn">new scale to scale to. Can be null</param>
2962
2979
/// <param name="teleportDisabled">When true (the default) the <see cref="NetworkObject"/> will not be teleported and, if enabled, will interpolate. When false the <see cref="NetworkObject"/> will teleport/apply the parameters provided immediately.</param>
2963
- /// <exception cref="Exception"></exception>
2980
+ /// <exception cref="Exception">Thrown when the function is called on non-spawned object or, when it's called without proper authority </exception>
2964
2981
public void SetState ( Vector3 ? posIn = null , Quaternion ? rotIn = null , Vector3 ? scaleIn = null , bool teleportDisabled = true )
2965
2982
{
2966
2983
if ( ! IsSpawned )
@@ -3023,7 +3040,7 @@ private void SetStateInternal(Vector3 pos, Quaternion rot, Vector3 scale, bool s
3023
3040
3024
3041
var transformToCommit = transform ;
3025
3042
3026
- // Explicit set states are cumulative during a fractional tick period of time (i.e. each SetState invocation will
3043
+ // Explicit set states are cumulative during a fractional tick period of time (i.e. each SetState invocation will
3027
3044
// update the axial deltas to whatever changes are applied). As such, we need to preserve the dirty and explicit
3028
3045
// state flags.
3029
3046
var stateWasDirty = m_LocalAuthoritativeNetworkState . IsDirty ;
@@ -3111,7 +3128,9 @@ private void UpdateInterpolation()
3111
3128
}
3112
3129
}
3113
3130
3114
- /// <inheritdoc/>
3131
+ /// <summary>
3132
+ /// This method is called once per frame.
3133
+ /// </summary>
3115
3134
/// <remarks>
3116
3135
/// If you override this method, be sure that:
3117
3136
/// - Non-authority always invokes this base class method.
@@ -3134,10 +3153,10 @@ protected virtual void Update()
3134
3153
/// <summary>
3135
3154
/// Teleport the transform to the given values without interpolating
3136
3155
/// </summary>
3137
- /// <param name="newPosition"></param> new position to move to.
3138
- /// <param name="newRotation"></param> new rotation to rotate to.
3156
+ /// <param name="newPosition">new position to move to.</param>
3157
+ /// <param name="newRotation">new rotation to rotate to.</param>
3139
3158
/// <param name="newScale">new scale to scale to.</param>
3140
- /// <exception cref="Exception"></exception>
3159
+ /// <exception cref="Exception">Thrown if teleporting is attempted on a non-authoritative side. </exception>
3141
3160
public void Teleport ( Vector3 newPosition , Quaternion newRotation , Vector3 newScale )
3142
3161
{
3143
3162
if ( ! CanCommitToTransform )
0 commit comments