Rigidbody Component: Networked Velocity, Proxy Physics Simulation, Impact Damage, and SmoothMove
Rigidbody Component: Networking, Velocity Sync, and Proxy Physics Simulation
The Rigidbody component is the primary way to add physics simulation to a GameObject. It implements IScenePhysicsEvents and IGameObjectNetworkEvents for deep physics-network integration.
Key Properties
rb.Velocity // linear velocity (reads from proxy's NetworkedVelocity on proxies)
rb.AngularVelocity // angular velocity
rb.Mass // read-only, from PhysicsBody
rb.MassOverride // override mass (0 = use calculated mass)
rb.Gravity // enable/disable gravity
rb.GravityScale // multiplier on world gravity
rb.LinearDamping // linear drag
rb.AngularDamping // angular drag
rb.MotionEnabled // true = Dynamic, false = Keyframed
rb.Sleeping // true if body is sleeping
rb.StartAsleep // start in sleep state
rb.Locking // PhysicsLock flags (freeze axes)
rb.EnhancedCcd // continuous collision detection for fast objects
rb.CollisionEventsEnabled // enable OnCollisionStart/Stop
rb.CollisionUpdateEventsEnabled // enable OnCollisionUpdate (persistent)
rb.PhysicsBody // the underlying PhysicsBody (may be null)Networked Velocity
Rigidbody syncs velocity via [Sync] properties:[Sync] private Vector3 NetworkedVelocity { get; set; }
[Sync] private Vector3 NetworkedAngularVelocity { get; set; }These are updated in PrePhysicsStep() only when the body is awake and moving, to avoid unnecessary network traffic. Before dropping ownership, BeforeDropOwnership() forces a final sync.
Proxy Physics Simulation
A key behavior: proxies simulate physics locally when NetworkFlags.NoTransformSync is set:
bool ShouldSimulatePhysics =>
!IsProxy ||
GameObject.NetworkMode != NetworkMode.Object ||
GameObject.Network?.Flags.Contains( NetworkFlags.NoTransformSync ) == true;When ShouldSimulatePhysics is false (normal proxy), the body uses Move() to follow the network transform. When true, the proxy runs its own physics simulation.
Impact Damage
Rigidbody automatically deals damage on high-speed impacts:rb.EnableImpactDamage = true;
rb.MinImpactDamageSpeed = 500f; // minimum speed to trigger damage
rb.ImpactDamage = 0f; // 0 = calculated from mass (mass / 10)Both the rigidbody itself and the object it hits can receive damage via IDamageable.OnDamage(). The damage is tagged with "impact".
SmoothMove
For grabbing and moving objects cooperatively with physics:
rb.SmoothMove( targetTransform, timeToArrive: 0.1f, timeDelta: Time.Delta );
rb.SmoothMove( targetPosition, timeToArrive: 0.1f, timeDelta: Time.Delta );
rb.SmoothRotate( targetRotation, timeToArrive: 0.1f, timeDelta: Time.Delta );