🎢Motion Path

Animate objects in 3d with a Bezier path and velocity curve

Use Motion Path to animate objects in 3D space with advanced curve editing features to take full control over an object's position, rotation, and velocity over time.

Avoid using on objects with an Animator component

Motion Path initially exposes 1 channel, Path Position, and may optionally expose Path Rotation and Velocity channels.

When a new Motion Path is created, a start and end keyframe are added automatically starting at the current time. This is to help get started though these keyframes may be changed or deleted.

Velocity Curves

Path Position is a special type of channel combining position and velocity in one. Each keyframe relates to a node on the path and also determines velocity over time.

In the Graph View, a single curve is displayed depicting the object's relative velocity.

This curve displays relative velocity from one keyframe to the next. Each keyframe Value (as seen in the Info Panel) is the total average velocity from one keyframe to the next and is automatically calculated based on its distance and time from the previous keyframe.

Note that the Path Position velocity curve is relative, not absolute. To work with the final computed velocity of an object, see Velocity Channel.

Velocity Calculation

When moving a keyframe in time you'll notice that the curve and velocity values automatically adapt due to the mathematical constraints of the formulae shown below.

Velocity is calculated between two keyframes A and B as follows:

velocity = Distance(A.position, B.position) / (B.time - A.time)

Or in simpler terms:

velocity = distance / seconds (i.e. units per second)

The curve between keyframes then determines how the velocity is distributed over time. Since the total average velocity must add up to cover the distance over time, speeding up one half of the curve requires slowing down the other half.

Velocity Curve Examples

Following are some examples to illustrate how velocity curves behave.

If the path curve reaches the target position too soon, the path becomes flat for the remaining time. This means the object reaches the next keyframe position early and holds that value for the remaining duration.
Any time the velocity curve flattens out, the object slows to a stop at that point.
If a velocity curve starts fast then dips back down, the object travels retrograde along the path during the time the curve is descending, but ultimately catches back up.

Refer to the Graph View documentation for more curve editing features.

For alternate methods of animating objects along a Motion Path, see Place On Path.

Motion Path Editor

Select the object to view its settings in the Inspector.

For common features, see Menu Bar and Update Settings.

Interpolation

Interpolation Mode

Select one of the following path interpolation modes.

  • Hold: The path does not interpolate and the object remains fixed at each keyframe position.

  • Linear: Interpolates in a straight line from one position keyframe to the next.

  • Bezier: Full curve editing features with 3D Bezier tangents.

Close Path

If enabled, the path is forced to be a closed shape. Use this for circular and looping paths.

Rotation Mode

Select one of the following modes to determine how rotation is calculated:

  • None: No rotation is calculated. Use this mode to animate rotation separately.

  • Interpolate: Interpolates the rotations of each keyframe node.

  • Look Ahead: Automatically rotates by looking ahead on the path.

Look Ahead Time

Sets the time in seconds to look ahead on the path for Look Ahead interpolation.

Expose Target Object

When using Look Ahead, enable this option to expose the look target in the hierarchy view as a game object. This object is managed by Motion Path and should not be deleted or moved.

The main reason to expose the look target is to use it for other calculations or behaviors. For example, it could be used as the look target for other objects, or an object could be placed at the look position by making it a child or connecting it using Channel Link.

Up Vector

This settings only applies to Look Ahead rotation and determines the upward direction of the object for the look at calculation. This expects a normalized value (adding up to 1) defining a cardinal direction. Usually this value is (0, 1, 0) though may be changed if the object is oriented on a different plane.

See the Unity documentation on Vector3.

Orientation

Adds rotation in Euler angles to the object overall. Use this to orient the object. The property may also be animated to apply additional rotation to that already calculated by the motion path.

Other ways of animating rotation

An alternative to the rotation modes above is to use a separate behavior or animation channel. Object rotation can be animated independently using a standard animation channel or a behavior such as Auto Rotate .

To use an alternate method, make sure to set the Rotation Mode to None.

Auto Tangent Ratio

Controls how 3D Bezier tangents are calculated for keyframes using Auto Calculate. The slider represents the tangent lengths relative to its neighboring nodes. This affects the degree of curving with a value of 0 being linear (no tangent length) and a value of 1 being maximum tangent length.

The ratio is multiplied with the Weight value of each node, so you may adjust the degree of bending on a per-keyframe basis. See the Motion Path Nodes section below.

Enable Auto Update for keyframe nodes to automatically recalculate tangents

This only affects keyframes set to Auto Calculate mode, which can be set in the Scene View or in the node details.

Position Smoothing

Applies temporal smoothing to the position based on time in seconds. Use this to create smoother object motions, when adhering to the path is not as important.

Position Smoothing dampens the movement of the object using a time delay, causing it to round corners and has a softening/reducing effect on the curve overall.

Rotation Smoothing

Applies temporal smoothing to rotation over time in seconds.

Rotation Smoothing delays an object's rotation. Larger values may cause the rotation to lag behind the path's rotation.

Motion Path Nodes

The Nodes section displays a list of all keyframe nodes on the path.

Expand / Collapse

Each node may be expanded using the foldout arrow on the left to further edit specific details. Use the buttons Expand All and Collapse All to open or close details for all nodes.

To help facilitate keyframe editing, each node is automatically expanded and highlighted in the inspector when keyframes are selected in either the scene or Timeflow views.

Expose Nodes

Each keyframe on a motion path is associated with a node object. These are objects are hidden from the hierarchy view by default to reduce clutter in the project, however may be revealed for additional uses or direct editing of the game objects.

The nodes exposed in the hierarchy view

By using game objects to represent nodes on a motion path, more advanced features are possible and makes path nodes easily accessed by other scripts. Objects may also be placed relative to nodes on a path, and nodes can be used to influence other behaviors. Nodes can be hidden again at any time by unchecking Expose Nodes. Also see Place On Path for another way to place objects relative to a path or node.

Beware of making objects children of nodes

When nodes are exposed in the hierarchy, selecting one or more objects shows its details in the inspector. These are the same parameters shown in the Nodes section above, however this method supports multi-object editing so you can change attributes multiple nodes at once.

The motion path automatically detects changes to position and rotation as long as Timeflow is not playing. Changes may be applied directly by editing the fields in the inspector for one or multiple objects.

Note that if you use the move and rotate tools on a selected node object in the scene view, the selection reverts back to the Motion Path for full editing features.

Locking Nodes

Each keyframe node may be locked in time and/or value to prevent changes to it. To lock all keyframes at once, use the Lock All and Unlock All buttons.

Keyframe nodes may also be locked/unlocked in the Scene View and Timeflow view.

Clear All

Deletes all keyframes and nodes from the path.

Expose ID

This makes a keyframe node accessible to other scripts to set its value remotely. This is an advanced scripting feature only used for special setups where a motion path is modified by a custom script. For more about this feature, please see the documentation for Exposed Keyframes.

Tools & Options

Show Gizmos

Enable this to display the 3D path and editing tools in the Scene View. The color may be set independently from the channel color and may be adjusted as preferred.

Note that Gizmos must be enabled in the Scene view for the motion path and editing features to be displayed. This is covered in more detail below.

Stay Visible

If enabled, the path remains visible in the Scene View even when the object is not selected. Otherwise, the path and gizmos are only displayed when the object is the active selection.

This setting only affects the visibility of the path. The editing controls are only ever displayed when the motion path or one of its nodes are selected.

Can Edit

This enables the motion path editing tools displayed in the Scene View. See the Gizmos / Scene View section below for further information.

Rotation Channel

Enable this to expose the object rotation as a separate read-only channel. This outputs the final rotation of the object which may be used with Channel Link to drive other behaviors.

Velocity Channel

Enable to expose a separate read-only velocity channel outputting the final velocity of the object. This is not to be confused with the relative velocity curve in the Path Position channel.

  • Vector: velocity as a Vector3

  • Speed: velocity in units per second (vector length)

  • Interpolation: current path interpolation from 0-1 over full length of path

Depending on the mode selected the Path Velocity may either be a float or Vector3 channel.

Read-Only at Current Time

Bounding Frames

This is an editor tool for visualization and scene construction. When enabled, square bracket shapes are drawn along the path in the Scene View.

Bounding frames are a helpful visual aid to see the shape of the path in 3D and to identify any issues with velocity and rotation.

The default settings display rectangles along the path, enabled by Draw Rectangles. Adjust the Size and Count as desired.

The frames are spaced according to the path velocity if Use Velocity is enabled, otherwise they are spaced evenly over the distance of the path. Adjust the Start and End to limit the frames to a specific part of the path.

Prefab & Generate Objects

Any game object or prefab may be replicated along the path. When an object is assigned, mesh instances are drawn in the Scene View as a preview however the objects are not visible in the camera until generated as game objects.

Notify On Setup

This is both an editor and runtime feature to notify other components when the motion path has been setup or modified. This is particularly useful to update other behaviors that base their positioning on the path, such as when using Follow or Place On Path.

Click the + button to add a component function. This only works for methods without parameters.

Gizmos / Scene View

Additional path editing tools are displayed in the Scene View while the object is selected.

Keyframe Selection

Each keyframe node is displayed as a yellow dot. Click on a keyframe to select it. The selected key is displayed with a movable position handle, which can also be rotated by switching to the Rotate tool in the Unity toolbar.

When viewing the motion path in the Scene View and in Timeflow at the same time, selecting a keyframe in either view selects it in the other.

Add Key

Click to insert a new keyframe at the current time.

This button is disabled if there is already a keyframe at the current time.

Prev / Next

Selects the next or previous keyframe. Use this to iterate through the keyframe nodes.

Select

Use this menu to select all nodes, deselect all, or select the first or last node.

Lock / Unlock

Click the lock icon to toggle the locked state of the currently selected keyframes. Locked keyframes are displayed with a small lock next to them.

Locked keyframes can still be selected but not moved or modified.

Tangents

When using Bezier interpolation, each selected keyframe displays tangent handles to edit the shape of the curve. Click and drag on the tangent handles to modify them.

The tangent handles are displayed as small cubes connected by the red line extending from the keyframe.

Auto Calculate

Keyframes may be set to auto calculate tangents which approximates handles based on its position relative to the neighboring nodes.

Auto Calculate performs an educated guess at the shape desired, however it is unavoidable that it will sometimes produce undesired results. This mode works best for intermediate keyframes and can be helpful when creating a path to get the approximate shape before manually fine tuning each keyframe.

When Auto Calculate is enabled, the keyframe tangent line is displayed in cyan (rather than red)

Enable Tangent Auto Update to continuously update keyframes with Auto Calculate enabled. This results in a flexible path that dynamically adapts to changes.

Break / Unify

By default tangents are unified, meaning that adjusting one side affects the other and they remain connected in a straight line. However tangents may be broken to independently edit each side.

Break tangents to create a hard angle or abrupt change.

Collapse

This command sets the tangents to 0 length resulting in a hard angle. This can be used to make keyframe nodes linear rather than curved.

Expand

Automatically calculates tangents based on the keyframe position relative to other nodes.

Show / Hide

Use these commands to show and hide the tangent controls for selected keyframes. This has no effect on the shape of the path and simply determines whether the UI controls are displayed.

Once tangents have been set for keyframes, you may want to hide them to prevent further changes without first showing them again.

Flatten

Use these options to set tangents to zero, flattening them on the specified plane.

Delete Node

Deletes the selected keyframe nodes. This has the same effect as deleting keyframes in the Timeflow view or Inspector.

Additional Notes

Broken Path?

At some point you may encounter a situation where the path in the scene view flattens out or has a linear segment that doesn't make sense and appears to be broken.

The path shape cutting across in a straight line is caused by a jump in velocity.

This is a result of the velocity curve shown below. This can happen after inserting a new keyframe and requires adjusting the tangents and keyframe timing to balance out the curve.

Because the tangent of the first keyframe is so extreme, it is causing the velocity to jump in order to reach the next keyframe position on time.
Adjust the tangents to create a smoother velocity curve.

Once the kinks in the velocity curve have been smoothed out, the 3D curve appears correctly.

Last updated