Shape Follow

The Shape Follow component allows you to easily make objects follow a spline or multiple splines with different weights as well as optionally having the object rotate to align with the spline. You can add any number of splines to follow and adjust their weights so allowing for easy transitioning from one path to another. When using the system a blue and yellow path will be displayed which is the combined path of all the targets based on their weights and offsets etc so you can visualize where the object will go and how weights etc will alter the path.

Shape Follow Params


You can choose to position your object on the shape either via an Alpha value ie 0 to 1 with 0 being the start of the path 1 being the end, or using the Distance mode where you control the position via a distance along the shape value, this is easier to understand for moving characters etc.


If the mode is Alpha then this slider will control the position. 0 is the start of the path and 1 the end, out of range values are allowed and the system will either loop on closed splines or extrapolate on open splines.


The distance to along the path to position the object, again the system allows out of range values and will loop or extrapolate as needed.


The amount to look ahead to calculate the rotation of the object if Rot is set.


How fast to move along the path, if mode is Alpha then this value is scaled down by 1000 for easier control, if mode is Distance then this is distance moved in a second.


Check to have the object rotate as it moves along the path.


Allows you to reposition your object away from the path, handy if your pivot is not quite in the right place etc.


If the calculated rotation is not correct for your needs you can add in an extra rotation to fix it up.

Loop Time

If this value is non zero then the system will animate the object so that it will complete a full traversal of the path in this number of seconds.

Current Time

The current time for animated movement along the shape.

Draw Path

Check this to display a yellow and blue end path for your current targets and weights.

Gizmo Detail

How smooth to draw the path.

Late Update

Check this if you want the objects transform updated in the LateUpdate, you may need to set this if your object judders while moving.


If no targets are currently set then this button will allow you to add your first target.

Target Params


The shape you want to follow.


If the selected shape has more than one spline then you can select the spline to use with this slider.


How much this target contributes to the end result.


You can change the effective starting point on the spline for this target, so setting a value of 0.5 would mean the object would start half way along this spline if the main alpha or distance value above is 0.


You can effectively change the length of the target spline by changing this value, a value of 0.5 would make the spline seems twice as long to the system for example.


Click to Add a new target to the system.


Click to remove this target from the system.

Shape Follow Classes

public class MegaPathTarget
    public float        Weight;
    public MegaShape    shape;
    public int          curve;
    public float        modifier;
    public float        offset;

public class MegaShapeFollow : MonoBehaviour
    public float    Alpha;
    public float    distance;
    public MegaFollowMode   mode;
    public float    tangentDist;
    public float    speed;
    public bool     rot;
    public float    time;
    public float    ctime;
    public float    gizmodetail;
    public bool     drawpath;
    public Vector3  rotate;
    public Vector3  offset;
    public bool     lateupdate;
    public List<MegaPathTarget> Targets;


This simple class will move an object along a Shape Follow using the W and S keys.

using UnityEngine;

// Example script to move an object along a Mega Shape Follow using keys
public class MovePlayer : MonoBehaviour
    public float distance = 0.0f;   // Position
    public float speed = 1.0f;      // Movement speed
    public MegaShapeFollow  follow; // follow object

    void Start()
        if ( !follow )
            follow = (MegaShapeFollow)GetComponent<MegaShapeFollow>();

        if ( follow )
            follow.mode = MegaFollowMode.Distance;

    void Update()
        if ( Input.GetKey(KeyCode.W) )
            distance += speed * Time.deltaTime;

        if ( Input.GetKey(KeyCode.S) )
            distance -= speed * Time.deltaTime;

        if ( follow )
            follow.distance = distance;


You must be logged in to post a comment.