@@ -46,10 +46,24 @@ namespace Unity.Netcode.Components
4646 [ DefaultExecutionOrder ( 100000 ) ] // this is needed to catch the update time after the transform was updated by user scripts
4747 public class AnticipatedNetworkTransform : NetworkTransform
4848 {
49+ /// <summary>
50+ /// Represents the state of a transform, including position, rotation, and scale.
51+ /// </summary>
4952 public struct TransformState
5053 {
54+ /// <summary>
55+ /// The position of the transform.
56+ /// </summary>
5157 public Vector3 Position ;
58+
59+ /// <summary>
60+ /// The rotation of the transform.
61+ /// </summary>
5262 public Quaternion Rotation ;
63+
64+ /// <summary>
65+ /// The scale of the transform.
66+ /// </summary>
5367 public Vector3 Scale ;
5468 }
5569
@@ -242,6 +256,9 @@ public void AnticipateState(TransformState newState)
242256 m_CurrentSmoothTime = 0 ;
243257 }
244258
259+ /// <summary>
260+ /// Updates the AnticipatedNetworkTransform each frame.
261+ /// </summary>
245262 protected override void Update ( )
246263 {
247264 // If not spawned or this instance has authority, exit early
@@ -350,6 +367,13 @@ private void ResetAnticipatedState()
350367 m_CurrentSmoothTime = 0 ;
351368 }
352369
370+ /// <summary>
371+ /// Invoked when a new client joins (server and client sides).
372+ /// Server Side: Serializes as if we were teleporting (everything is sent via NetworkTransformState).
373+ /// Client Side: Adds the interpolated state which applies the NetworkTransformState as well.
374+ /// </summary>
375+ /// <typeparam name="T">The type of the serializer.</typeparam>
376+ /// <param name="serializer">The serializer used to serialize the state.</param>
353377 protected override void OnSynchronize < T > ( ref BufferSerializer < T > serializer )
354378 {
355379 base . OnSynchronize ( ref serializer ) ;
@@ -361,6 +385,9 @@ protected override void OnSynchronize<T>(ref BufferSerializer<T> serializer)
361385 }
362386 }
363387
388+ /// <summary>
389+ /// Invoked when the NetworkObject is spawned.
390+ /// </summary>
364391 public override void OnNetworkSpawn ( )
365392 {
366393 base . OnNetworkSpawn ( ) ;
@@ -373,6 +400,9 @@ public override void OnNetworkSpawn()
373400 NetworkManager . AnticipationSystem . AllAnticipatedObjects . Add ( m_AnticipatedObject ) ;
374401 }
375402
403+ /// <summary>
404+ /// Invoked when the NetworkObject is despawned.
405+ /// </summary>
376406 public override void OnNetworkDespawn ( )
377407 {
378408 if ( m_AnticipatedObject != null )
@@ -387,6 +417,9 @@ public override void OnNetworkDespawn()
387417 base . OnNetworkDespawn ( ) ;
388418 }
389419
420+ /// <summary>
421+ /// Invoked when the NetworkObject is destroyed.
422+ /// </summary>
390423 public override void OnDestroy ( )
391424 {
392425 if ( m_AnticipatedObject != null )
@@ -438,19 +471,30 @@ public void Smooth(TransformState from, TransformState to, float durationSeconds
438471 m_CurrentSmoothTime = 0 ;
439472 }
440473
474+ /// <summary>
475+ /// Invoked just before the authoritative state is updated and pushed to non-authoritative instances.
476+ /// </summary>
441477 protected override void OnBeforeUpdateTransformState ( )
442478 {
443479 // this is called when new data comes from the server
444480 m_LastAuthorityUpdateCounter = NetworkManager . AnticipationSystem . LastAnticipationAck ;
445481 m_OutstandingAuthorityChange = true ;
446482 }
447483
484+ /// <summary>
485+ /// Invoked when the NetworkTransform state is updated.
486+ /// </summary>
487+ /// <param name="oldState">The previous state of the NetworkTransform.</param>
488+ /// <param name="newState">The new state of the NetworkTransform.</param>
448489 protected override void OnNetworkTransformStateUpdated ( ref NetworkTransformState oldState , ref NetworkTransformState newState )
449490 {
450491 base . OnNetworkTransformStateUpdated ( ref oldState , ref newState ) ;
451492 ApplyAuthoritativeState ( ) ;
452493 }
453494
495+ /// <summary>
496+ /// Invoked whenever the transform has been updated.
497+ /// </summary>
454498 protected override void OnTransformUpdated ( )
455499 {
456500 if ( CanCommitToTransform || m_AnticipatedObject == null )
0 commit comments