Skip to main content

RotateToTargetWorldXZ

A class in Root.Township, Alta.Intelligence.

Networked component that turns a jointed body part toward the creature's target (or a default point) by driving a ConfigurableJoint around its X axis. The server picks the angle and syncs it; both sides apply it.

Constructors​

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

Fields​

MemberWhat it is
static AccumulativeAverageCount prepareForWriteTimerStatic profiling counter shared by every instance.
static AccumulativeAverageCount serializeTimerStatic profiling counter shared by every instance.
8 private and internal fields
MemberWhat it is
private Agent agentThe creature whose target is followed.
private ConfigurableJoint configurableJointThe joint whose target rotation is driven.
private Transform defaultTargetPoint faced when the creature has no living target.
private float lastSyncRotationAngle at the last delta write, for change detection.
private float lerpSerialized but not used by this code.
private Rigidbody rigidbodyThe rigidbody on this GameObject. Fetched but not otherwise used.
private float targetRotationThe current target angle in degrees, set by the server and synced to clients.
private Transform topicTransform that is given this object's rotation every frame.

Properties​

3 private and internal properties
MemberWhat it is
private int Alta.Networking.INetworkSerialized.MaximumBits { get; }12 bits per sync: the target angle.
private AccumulativeAverageCount Alta.Networking.INetworkSerialized.PrepareForWriteTimer { get; }Shared profiling counter for PrepareForWrite.
private AccumulativeAverageCount Alta.Networking.INetworkSerialized.SerializeTimer { get; }Shared profiling counter for Serialize.

Methods​

MemberWhat it is
void RemoveLimits()Opens the joint's angular Y and Z limits to 90 degrees.
4 private and internal methods
MemberWhat it is
private void Awake()Gets the ConfigurableJoint and Rigidbody on this GameObject.
private void LateUpdate()Server: works out the angle to the target's ground position. Both sides: set it as the joint's target rotation and copy this rotation to topic.
private bool Alta.Networking.INetworkSerialized.PrepareForWrite(bool isWriteFull)Reports whether the angle changed since the last delta write.
private void Alta.Networking.INetworkSerialized.Serialize(Stream stream, bool isWriteFull)Sends the angle between -180 and 180 at 0.1 degree steps.