IndependentWalker
A class in Root.Township, Alta.Pathfinding.
Lets an Agent's navigator child detach and walk on its own, while the agent's rigidbody follows and turns toward it each frame. Sits next to a Navigator.
- Listed in Creatures and AI
- Inherits or implements
MonoBehaviour - Attributes
RequireComponent - Documented in Movement and pathfinding
Constructors
| Member | What it is |
|---|---|
IndependentWalker() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
9 private and internal fields
| Member | What it is |
|---|---|
private Agent baseTopic | The agent whose rigidbody follows this walker. |
private Transform cachedTransform | Cached transform of the walker. |
private bool isAttached | Whether the walker is parented to the agent and not driving it. |
private bool isFollowingByDefault | Detaches on Start so the agent follows from the beginning. |
private float movementSpeed | Metres per second the agent moves toward the walker. |
private Navigator navigator | The Navigator on the same object, teleported on detach. |
private float rotationSpeed | Degrees per second the agent turns toward the walker. |
private static UpdateModule updateModule | Shared update module for all independent walkers. |
private IUnityUpdateMethod updatePosition | The registered UpdatePosition method while detached. |
Methods
7 private and internal methods
| Member | What it is |
|---|---|
private void BaseDestroyed(NetworkEntity entity, bool isUnload) | Destroys the walker when the agent's entity is destroyed. |
private void Destroyed() | Unhooks from the agent, destroys the walker's GameObject and stops the update. |
private void InternalDettach(bool isRepositioning) | Detaches if attached and the agent is alive, hooks the agent's death and destroy events, and starts UpdatePosition. |
private void OnBaseKilled(DamageData lastHit) | Destroys the walker when the agent dies. |
private void OnDestroy() | Removes the update method. |
private void Start() | Caches the transform and detaches straight away when isFollowingByDefault is on. |
private void UpdatePosition() | Moves the agent's rigidbody toward the walker at movementSpeed and turns it toward the walker at rotationSpeed. |