Physics Synchronization
GONet provides first-class support for networked physics. Rigidbody components are auto-discovered for sync, a dual time system keeps physics deterministic across clients, and centralized update loops eliminate per-object callback overhead.
FixedUpdateAfterGONetReady
Just as GONet provides UpdateAfterGONetReady() as a more efficient alternative to Unity's Update(), it also provides FixedUpdateAfterGONetReady() for physics logic.
public class Vehicle : GONetParticipantCompanionBehaviour
{
private Rigidbody rb;
internal override void FixedUpdateAfterGONetReady()
{
if (IsMine)
{
// Apply forces, handle physics input
rb.AddForce(inputDirection * speed);
}
}
}- •Guaranteed readiness -- Only called after the participant is fully initialized. No need for defensive null checks or readiness guards.
- •Centralized iteration -- N objects = 1 internal loop call, not N separate Unity FixedUpdate() callbacks. Same performance advantage as UpdateAfterGONetReady().
- •LateUpdateAfterGONetReady -- Also available for post-physics logic (camera follow, IK, etc.).
Dual Time System
GONet maintains two independently synchronized time systems to keep game logic and physics in lockstep across all clients, even when frame rates vary.
Standard Time
Updated each frame. Used for interpolation, event timestamps, and general game logic. Access via ElapsedSeconds.
Physics Time
Updated each FixedUpdate() call. Used for physics-based synchronization. Access via FixedElapsedSeconds.
Physics time uses a Direct Gap Addition algorithm that catches up to standard time in O(1) -- no iteration limits, handles any gap size (even 30+ second gaps during scene transitions), and guarantees monotonicity (time never goes backward).
Rigidbody Auto-Discovery
GONet automatically detects Rigidbody components on GONetParticipant objects and configures sync accordingly. No manual setup is required.
- •Companion class optimization -- The code generation pipeline checks for Rigidbody presence once at compile time, not per-frame at runtime.
- •Physics-gated intervals -- Rigidbody velocity sync uses physics-gated intervals (Time.fixedDeltaTime * PhysicsUpdateInterval) instead of frame-based intervals.
- •Velocity-augmented sync -- Works with physics objects. Rigidbody velocity is used as the velocity source for extrapolation, producing smooth results for moving physics objects.
Kinematic Auto-Management
When a GONetParticipant with a Rigidbody is reparented under another syncing GONetParticipant (e.g., a player picking up an object), GONet automatically manages the physics state:
- •On attach -- Rigidbody is set to kinematic and gravity is disabled. This prevents the child object from fighting with the parent's transform sync.
- •On detach -- Original kinematic and gravity settings are restored automatically.
- •Configurable -- Controlled by AutoKinematicOnTransformSyncSuspension (default: true). Disable if you need manual control over physics state during reparenting.
Best Practices
- •Use FixedUpdateAfterGONetReady() for all physics logic instead of FixedUpdate().
- •Enable velocity-augmented sync on physics objects for maximum bandwidth savings -- Rigidbody velocity is naturally well-suited for extrapolation.
- •Let GONet handle kinematic toggling during reparenting. Only disable AutoKinematicOnTransformSyncSuspension if your game has custom physics attachment behavior.
- •Quantize physics values (16-bit for positions, 8-bit for angular velocity) to reduce bandwidth without perceptible precision loss.
Next Steps
- →Runtime Re-parenting -- How GONet handles dynamic parent changes with sync suspension and position guards.
- →Time Synchronization -- Deep dive into the dual time system and correction strategies.
- →Performance -- Velocity-augmented sync, SoA blending, and quantization strategies.