HoverAnimator
A class in Root.Township, the global namespace.
Bobs a set of transforms around their start positions using per-axis curves, plus any DragTrigger pull. Can stop and ease back to the start.
- Listed in Global namespace: E to H
- Inherits or implements
MonoBehaviour,IIgnoreForStaticFlatten,IDontSplit - Nested types
HoverAnimationState
Constructors
| Member | What it is |
|---|---|
HoverAnimator() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
14 private and internal fields
| Member | What it is |
|---|---|
private Vector3 animationLengths | Length of each axis curve. |
private Vector3 animationStartTimes | First key time of each axis curve. |
private HoverAnimator.HoverAnimationState[] animationStates | Per transform state: start position, time offset and drag trigger. |
private Dictionary<SnapAxis, AnimationCurve> axisCurves | Axis to curve lookup. |
private AnimationCurve hoverXAnimation | Curve for the x offset. |
private AnimationCurve hoverYAnimation | Curve for the y offset. |
private AnimationCurve hoverZAnimation | Curve for the z offset. |
private bool isPlaying | Whether the hover is running. Starts true. |
private bool isRandomisedOffsetPerTransform | Not read in this build: offsets are always random. |
private float magnitudeScale | Multiplier on the hover offset. |
private float resetMovementSpeed | Speed used to move back to the start after stopping. |
private Coroutine resetPositionRoutine | The running return to start coroutine, if any. |
private float timeScale | Multiplier on animation time. |
private Transform[] transformsToAnimate | The transforms that hover. |
Methods
| Member | What it is |
|---|---|
void PlayAnimation() | Stops any return to start and resumes hovering. |
void StopAnimation() | Stops hovering and starts easing back to the start position. |
7 private and internal methods
| Member | What it is |
|---|---|
private float EvaluateAnimation(SnapAxis axis, HoverAnimator.HoverAnimationState animationState, Func<Vector3, float> getValue) | Samples one axis curve for a transform at the current time with its offset, looping over the curve length. |
private void LateUpdate() | While playing, sets each transform's local position to start plus the scaled hover offset and drag pull. |
private void OnValidate() | Rebuilds the animation setup when edited. |
private IEnumerator ReturnToStartPosition() (iterator) | Coroutine: moves the first transform back to its start position at resetMovementSpeed. Other transforms stay where they are. |
private void SetupAnimation() | Reads each curve's start time and length and builds the axis to curve map. |
private void SetupAnimationStates() | Stores each transform's start position, a random time offset and its DragTrigger. |
private void Start() | Sets up the animation. |
Used in
Members of other types that take, return or hold a HoverAnimator: