Show / Hide Table of Contents

Class TweenRigidbody

Tween a kinematic Rigidbody's position or rotation with properly applying physics.

Inheritance
System.Object
TweenRigidbody
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 TweenRigidbody
Remarks

To make a tweened kinematic Rigidbody interact properly with other physics objects, there are two requirements:

  • Use Rigidbody.MovePosition and Rigidbody.MoveRotation to update the rigidbody's position (instead of Transform).
  • Update the rigidbody in FixedUpdate (instead of Update).

TweenRigidbody ensures both. It updates the Rigidbody with the proper methods and ensures the tween is set to update in FixedUpdate.

TweenRigidbody requires tweening 'position', 'rotation' or 'eulerAngles' on the transform the kinematic rigidbody is attached to. It's not possible to use TweenRigidbody with local position or rotation.

// Enable TweenRigidbody globally
Animate.Options.EnablePlugin(TweenRigidbody.Loader);

// Enable TweenRigidbody for a specific tween
Animate.To(transform, 5f, "position", Vector3(0, 0, 50))
.Rigidbody();

Methods

Loader(Tween, Boolean)

TweenRigidbody 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.

Rigidbody(Tween<Transform, Quaternion>)

Require the TweenRigidbody plugin for the current tween.

Declaration
public static Tween<Transform, Quaternion> Rigidbody(this Tween<Transform, Quaternion> tween)
Parameters
Type Name Description
Tween<Transform, Quaternion> tween
Returns
Type Description
Tween<Transform, Quaternion>
Remarks

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

Rigidbody(Tween<Transform, Vector3>)

Require the TweenRigidbody plugin for the current tween.

Declaration
public static Tween<Transform, Vector3> Rigidbody(this Tween<Transform, Vector3> tween)
Parameters
Type Name Description
Tween<Transform, Vector3> tween
Returns
Type Description
Tween<Transform, Vector3>
Remarks

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

Back to top © 2018 Adrian Stutz