WayPointPath
A class in Root.Township, the global namespace.
A networked, saved path of points with rotations that other code samples by distance (IPositionRotationPath). The server sends the points to each player who connects.
- Listed in Global namespace: T to X
- Inherits or implements
NetworkEntityBehaviour,IPositionRotationPath,ISavable<WayPointPathData>,ISavableSave<WayPointPathData>,ISavableSaveBase - Derived types
WayPointPathData
Constructors
| Member | What it is |
|---|---|
WayPointPath() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
5 private and internal fields
| Member | What it is |
|---|---|
private float[] lengths | Length of each segment between points. |
private Vector3[] positions | Backing field for Positions. |
private Quaternion[] rotations | Backing field for Rotations. |
private MethodSync syncPositions | Method sync that sends the points to players. |
private float totalDistance | Total path length, used for normalised lookups. |
Properties
| Member | What it is |
|---|---|
Vector3[] Positions { get; set; } | Point positions in world space. Setting it doesn't recompute lengths or resync. |
Quaternion[] Rotations { get; set; } | Point rotations, one per position. |
Methods
| Member | What it is |
|---|---|
static void GetPointFromArray(Vector3[] positions, Quaternion[] rotations, float[] lengths, ref float distance, out Vector3 position, out Quaternion rotation) | Static: walks the segment lengths to find the position and rotation at a distance along the points, clamped to the ends. PresetWayPointPath uses it too. |
override void Initialize() | Sets up the method sync that sends the points. |
override void InitializeAsServer(SpawnData spawnData) | Server: works out segment lengths from the loaded points. |
override void OnConnected(Player player) | Server: sends the points to a joining player. |
4 private and internal methods
| Member | What it is |
|---|---|
private void IPositionRotationPath.GetPosition(float value, out Vector3 position, out Quaternion rotation, bool isNormalized) | Gets the point at a distance along the path, or at a 0 to 1 fraction of it when isNormalized is true. |
private void OnDrawGizmosSelected() | Draws the path in the editor. |
private void SetupDistances() | Works out each segment length and the total length. |
private void SyncPositions(IPlayer player, Stream stream) | Writes or reads the points and rotations (15 at most). Clients rebuild the lengths after reading. |