Show / Hide Table of Contents

Class TweenSlerp

Tween a rotation using the shortest path from start to end.

Inheritance
System.Object
TweenSlerp
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ToString()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: Sttz.Tweener
Assembly: cs.temp.dll.dll
Syntax
public static class TweenSlerp
Remarks

TweenSlerp is enabled by default when tweening Quaternions, it's also used automatically when tweening a Vector3 where the property ends in "eulerAngles".

Vector3 can represent positions as well as rotations but tweening them does not work the same way. Positions can usually just be linearly interpolated (lerp - a basic tween), whereas that leads to unexpected behavior for rotations. E.g. tweening from (0, 10, 0) to (0, 350, 0) will take the long way around, while tweening (0, -20, 0) would be the shortest path.

Slerp (spherical lerp) solves this by always tweening the shortest possible path between two rotations.

// Disable TweenSlerp
Animate.Options.EnablePlugin(TweenSlerp.Loader, false);

// Require TweenSlerp for a single tween
Animate.To(transform, 2f, "eulerAngles", new Vector3(0, 180, 0))
.Slerp();

Methods

Loader(Tween, Boolean)

TweenSlerp plugin loader.

Declaration
public static PluginResult Loader(Tween tween, bool required)
Parameters
Type Name Description
Tween tween
System.Boolean required
Returns
Type Description
PluginResult
Remarks

Pass this method to EnablePlugin(PluginLoader, Nullable<Boolean>, Nullable<Boolean>) to enable the plugin for the options scope.

Slerp<TTarget>(Tween<TTarget, Quaternion>)

Require the TweenSlerp plugin for the current tween.

Declaration
public static Tween<TTarget, Quaternion> Slerp<TTarget>(this Tween<TTarget, Quaternion> tween)
    where TTarget : class
Parameters
Type Name Description
Tween<TTarget, Quaternion> tween
Returns
Type Description
Tween<TTarget, Quaternion>
Type Parameters
Name Description
TTarget
Remarks

Shorthand for using EnablePlugin(PluginLoader, Nullable<Boolean>, Nullable<Boolean>) with type-checking.

Slerp<TTarget>(Tween<TTarget, Vector3>)

Require the TweenSlerp plugin for the current tween.

Declaration
public static Tween<TTarget, Vector3> Slerp<TTarget>(this Tween<TTarget, Vector3> tween)
    where TTarget : class
Parameters
Type Name Description
Tween<TTarget, Vector3> tween
Returns
Type Description
Tween<TTarget, Vector3>
Type Parameters
Name Description
TTarget
Remarks

Shorthand for using EnablePlugin(PluginLoader, Nullable<Boolean>, Nullable<Boolean>) with type-checking.

Back to top © 2018 Adrian Stutz