Skip to main content

NetworkedJointDrivenRig

A class in Root.Township, the global namespace.

Syncs the rotations of a rig's rigidbody bones from the server; clients steer each bone toward its target with torque rather than setting it.

Constructors​

MemberWhat it is
NetworkedJointDrivenRig()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

MemberWhat it is
static AccumulativeAverageCount prepareForWriteTimerShared timing stats for PrepareForWrite.
static AccumulativeAverageCount serializeTimerShared timing stats for Serialize.
7 private and internal fields
MemberWhat it is
private float angleThresholdDegrees a bone must turn before it is sent again.
private Transform[] bonesBone transforms to sync; each needs a rigidbody.
private float fixedUpdateLerpTimeUnused in this build.
private bool[] isSendingBonesPer bone flags for the next write.
private Quaternion[] oldRotationsLast sent rotation per bone.
private Rigidbody[] rigidbodiesRigidbody on each bone.
private Quaternion[] targetRotationsLast sent or received rotation per bone.

Properties​

MemberWhat it is
bool IsHandlingRemote { get; set; }Whether clients drive the bones. Nothing in this build sets it.
3 private and internal properties
MemberWhat it is
private int Alta.Networking.INetworkSerialized.MaximumBits { get; }33 bits per bone.
private AccumulativeAverageCount Alta.Networking.INetworkSerialized.PrepareForWriteTimer { get; }Returns the shared prepareForWriteTimer.
private AccumulativeAverageCount Alta.Networking.INetworkSerialized.SerializeTimer { get; }Returns the shared serializeTimer.

Methods​

MemberWhat it is
bool PrepareForWrite(bool isWriteFull)Flags bones that turned at least angleThreshold since last sent.
void Serialize(Stream stream, bool isWriteFull)Writes or reads a flag and compressed rotation for each bone.
5 private and internal methods
MemberWhat it is
private void ApplyForceToRotateRigidbody(Rigidbody rigidbody, Quaternion targetRotation)Adds torque that turns a rigidbody toward a target rotation; skips and warns on NaN.
private void Awake()Sets up the rotation arrays and finds each bone's rigidbody.
private void FixedUpdate()Client: applies torque to every bone while IsHandlingRemote is on.
private void HandleRemote()Applies torque to every bone toward its received rotation.
private void SetupRotationArrays(ref Quaternion[] rotationArray)Fills a rotation array with identity, one per bone.