Skip to main content

ControlledRotateAndShake

A class in Root.Township, the global namespace.

Client: rotates a transform around X by a progress value and can shake it back and forth around Z for a random time.

Constructors​

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

Fields​

11 private and internal fields
MemberWhat it is
private Transform cachedTransformThe transform rotated.
private float currentRotationCurrent X rotation progress.
private float currentShakeCurrent shake value, 0 to 1.
private float currentShakeSpeedSeconds per swing for the current shake.
private MinMaxValue rotationX angle range mapped from progress.
private MinMaxValue shakeZ angle range mapped from the shake value.
private int shakeDirection1 or -1, the way the shake is swinging.
private MinMaxValue shakeDurationRange for how long a shake lasts.
private float shakeFinishTimeReal time when the shake stops.
private MinMaxValue shakeSpeedRange for seconds per swing.
private IUnityUpdateMethod shakeUpdateHandle for the registered shake update.

Methods​

MemberWhat it is
void AnimateShake()Starts or extends a shake for a random duration with a random speed. Does nothing headless.
void SetRotation(float progress)Public overload sets the X rotation progress (0 to 1); the private one applies both rotations.
3 private and internal methods
MemberWhat it is
private void OnDestroy()Removes the shake update.
private void SetRotation()Public overload sets the X rotation progress (0 to 1); the private one applies both rotations.
private void ShakeUpdate()Per-frame update that swings the shake value between 0 and 1 until the shake ends.