Skip to main content

ScriptedRotation

A class in Root.Township, the global namespace.

Animates a transform's local rotation between stored key rotations when Animate is called. Client only; removed on headless servers.

Constructors​

MemberWhat it is
ScriptedRotation()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

10 private and internal fields
MemberWhat it is
private float animationSpeedUnused: the animation always takes one second.
private bool btnSaveKeyInspector button that calls SaveKey.
private Transform cachedTransformCached own transform.
private int currentKeyIndex of the key it's at, or turning from.
private Quaternion[] keysThe stored local rotations.
private float progressAnimation progress from 0 to 1.
private int startingKeyKey it starts at.
private int targetKeyIndex of the key it's turning toward.
private IUnityUpdateMethod updateRegistered update method while animating.
private static UpdateModule updateModuleShared update module for all scripted rotations.

Methods​

MemberWhat it is
void Animate(int targetKey)Starts turning toward the key at the given index, unless it's already there or heading there.
4 private and internal methods
MemberWhat it is
private void Awake()Destroys itself on headless servers, otherwise snaps to the starting key.
private void OnValidate()Keeps startingKey inside the key list.
private void SaveKey()Editor: adds the current local rotation to keys if not already in it.
private void UpdateRotation()Lerps from the current to the target key over one second, then stops updating.