Class TweenRigidbody
Tween a kinematic Rigidbody's position or rotation with properly applying physics.
Inheritance
Inherited Members
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.MovePositionandRigidbody.MoveRotationto update the rigidbody's position (instead ofTransform). - Update the rigidbody in
FixedUpdate(instead ofUpdate).
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.