An abstract class in Root.Township, the global namespace.
Makes an object trail smoothly after a target's position plus an offset, in late update. Off on a dedicated server by default. LerpFollow and ScaledLerpFollow derive from it.
Constructors
| Member | What it is |
|---|
protected LerpFollowBase() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|
protected Transform cachedTransform | This object's transform. |
protected Vector3 oldPosition | Position from the last update. |
5 private and internal fields
| Member | What it is |
|---|
private bool isDisabledOnServer | When true, the component turns itself off on a server, except in a local test. |
private float lerpPerSecond | How fast it catches up with the target. |
private static UpdateModule staticUpdateModule | Shared LateUpdate module for all followers of this target type. |
private IUnityUpdateMethod updateModule | This follower's registration in the update module. |
private Vector3 worldOffset | World offset from the target position. Defaults to 0.5 up. |
Properties
| Member | What it is |
|---|
abstract T Target { get; } | The thing being followed. Following stops when it becomes null. |
protected abstract Vector3 TargetPosition { get; } | World position of the target. |
Methods
| Member | What it is |
|---|
virtual void SetTarget(T target) | Enables following when the target is not null. |
virtual void Start() | Snaps to the target, and disables itself on a server unless that is turned off. |
protected virtual void Moving(Vector3 from, Vector3 to) | Called each update with the old and target positions, for subclasses. |
3 private and internal methods
| Member | What it is |
|---|
private void MovementUpdate() | Runs in LateUpdate. Moves towards the target plus worldOffset by lerpPerSecond of the gap each second, or disables itself if the target is gone. |
private void OnDisable() | Stops the movement update. |
private void OnEnable() | Registers the movement update with the shared update module. |