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.
- Listed in Creatures and AI
- Inherits or implements
NetworkEntityBehaviour,INetworkSerialized - Attributes
ProfileNetworkSerialized
Constructors
| Member | What it is |
|---|---|
RotateToTargetWorldXZ() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|---|
static AccumulativeAverageCount prepareForWriteTimer | Static profiling counter shared by every instance. |
static AccumulativeAverageCount serializeTimer | Static profiling counter shared by every instance. |
8 private and internal fields
| Member | What it is |
|---|---|
private Agent agent | The creature whose target is followed. |
private ConfigurableJoint configurableJoint | The joint whose target rotation is driven. |
private Transform defaultTarget | Point faced when the creature has no living target. |
private float lastSyncRotation | Angle at the last delta write, for change detection. |
private float lerp | Serialized but not used by this code. |
private Rigidbody rigidbody | The rigidbody on this GameObject. Fetched but not otherwise used. |
private float targetRotation | The current target angle in degrees, set by the server and synced to clients. |
private Transform topic | Transform that is given this object's rotation every frame. |
Properties
3 private and internal properties
| Member | What 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
| Member | What it is |
|---|---|
void RemoveLimits() | Opens the joint's angular Y and Z limits to 90 degrees. |
4 private and internal methods
| Member | What 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. |