Table of Contents

DOLocalPath Method

Namespace
DG.Tweening

DOLocalPath(Rigidbody2D, Vector2[], float, PathType, PathMode, int, Color?)

public static TweenerCore<Vector3, Path, PathOptions> DOLocalPath(this Rigidbody2D target, Vector2[] path, float duration, PathType pathType = null, PathMode pathMode = null, int resolution = 10, Color? gizmoColor = null)

Tweens a Rigidbody2D's localPosition through the given path waypoints, using the chosen path algorithm. Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations

NOTE: to tween a Rigidbody2D correctly it should be set to kinematic at least while being tweened.

BEWARE: doesn't work on Windows Phone store (waiting for Unity to fix their own bug). If you plan to publish there you should use a regular transform.DOLocalPath.

Parameters

target Rigidbody2D
path Vector2[]

The waypoint to go through

duration float

The duration of the tween

pathType PathType

The type of path: Linear (straight path), CatmullRom (curved CatmullRom path) or CubicBezier (curved with control points)

pathMode PathMode

The path mode: 3D, side-scroller 2D, top-down 2D

resolution int

The resolution of the path: higher resolutions make for more detailed curved paths but are more expensive. Defaults to 10, but a value of 5 is usually enough if you don't have dramatic long curves between waypoints

gizmoColor Color?

The color of the path (shown when gizmos are active in the Play panel and the tween is running)

Returns

TweenerCore<Vector3, Path, PathOptions>