{{description>Easy Unity spline movement with Curvy Splines. With our controllers, simply move objects on splines. Extend them to implement your train controller for example.}} {{indexmenu_n>2}} ====== Controllers ====== Controllers are used to align or move GameObjects to Curvy Splines and Curvy Generator data like extrusion volumes or paths. * Spline Controller: Use the Spline Controller to align or move GameObjects to Curvy Splines. * UI Text Spline Controller: Similar to Spline Controller, but acts on UI elements * Path Controller: This controller works with [[:documentation:generator:start]] Paths * Volume Controller: This controller works with [[:documentation:generator:start]] Volumes

===== Reference ===== ====General==== ==Update In== Determines when the controller is updated: Update, LateUpdate or FixedUpdate ==Target Component== The component controlled by the controller: Transform, Rigidbody or Rigidbody2D ==Spline/Path/Volume== The source object the controller will follow ==Use Cache== //Spline Controller only.// Whether to use cached values when appropriate. Cached values are less precise but faster to use. ====Position==== ==Position Mode== Whether the position is a world unit (absolute) distance or relative distance. Relative positions are values from 0 to 1. For splines, relative position is the [[:documentation:splines:start#units|TF]] while for paths and volumes it is the ratio of the total length. ==Position== The position, using the above mode ====Cross Position==== //Volume Controller only.// This section defines the lateral position: == Cross Range == Defines the range within the cross section the controller uses. The base point (the point '0' refers to) can be altered by using [[:documentation:generator:modules:shapeextrusion#Shift]]. == Cross Position == Defines the position within the defined Cross Range == Cross Clamping == Defines what to do when trying to move over the defined range ====Motion==== ==Move mode== Determines whether the speed uses absolute or relative distances. See [[#Position Mode]] for more details about absolute and relative distances ==Speed== The speed of the movement ==Direction== The direction of the movement ==Clamping== Determines what to do when the source's end is reached: * **Clamp** - controller will stop * **Loop** - controller will start over at the opposite side * **PingPong** - controller switches direction ==Constraints== Defines what motions (position/rotations) are to be frozen, if any ==Play automatically== When enabled, the controller will start playing when entering the Play Mode. ====Connections handling==== //Spline Controller only.// This allows you to specify how a Spline Controller should move when reaching a [[:documentation:splines:connections|Connection]]. You can set one of the following behaviors: * **Current Spline**: the controller will continue moving on the current spline as if there were no connections. * **Follow Up Spline**: the controller will continue moving on the spline containing the Follow-Up if there is any, otherwise will continue moving on the current spline. * **Random Spline**: the controller continue moving on one of the connected splines, chosen randomly. * **Follow Up otherwise Random**: the controller will continue moving on the spline containing the Follow-Up if there is any, otherwise will continue moving on one of the connected splines, chosen randomly. * **Custom**: define your own connected splines selecting logic. You can do that by assigning a GameObject having a component that inherits from ConnectedControlPointsSelector. ==Allow direction changes== When enabled, this allows the controller to change its movement direction. If moving on a Follow-Up, it will use the Follow-Up heading. If moving on a random connection, it will change direction to backward if it is a spline's end, or forward if it is a spline's start. ==Reject divergent splines== Whether splines that diverge from the current spline with more than a specific angle should be excluded from the randomly selected splines ==Reject current spline== Whether the current spline should be excluded from the randomly selected splines ====Orientation==== The controller defines the object's rotation by aligning a Source vector (from the controller's source) with a Target vector (from the controller's GameObject) ==Source== Determines the source vector: * **None** - no vector is used. Choose this option if you want the controller to keep the rotation as it is * **Tangent** - the tangent (direction) is used * **Orientation** - orientation (Up-Vector) is used ==Target== //Available only if Source is different than None.// Determines the rotation axis to align the above value to ==Ignore direction== //Available only if Source is different than None.// If enabled, the orientation ignore the movement direction. If not, when the controller is moving backward, the orientation flips direction. ==Lock Rotation== //Available only if Source is equal to None.// When true, the controller will enforce the rotation to not change ==Direction Damping time== Adds a [[https://docs.unity3d.com/ScriptReference/Vector3.SmoothDamp.html|smooth damping]] to the Forward vector of the controlled object, with the specified duration ==Up Damping time== Adds a [[https://docs.unity3d.com/ScriptReference/Vector3.SmoothDamp.html|smooth damping]] to the Up vector of the controlled object, with the specified duration ====Offset==== //Available only if Source is different than None.// Applies an offset (lateral movement) on the GameObject's position, based on the Up/Orientation vector of the source. ==Offset Angle== The Angle (-180 to 180) starting from the Up vector, defining the direction to offset with ==Offset Radius== The distance to offset with ==Compensate Offset== Adjusts speed to match the change of travel distance due to offset ====Events==== You can react to certain events by adding a handler to the following [[https://docs.unity3d.com/Manual/UnityEvents.html|UnityEvents]]: ==OnInitialized== //Available for all controllers// Called when the controller is initialized. You usually don't need to wait for the controller to initialize before setting its properties. ==OnControlPointReached== //Available for SplineController and UITextSplineController only// Called when moving over a Control Point ==OnPositionReachedList== //Available for SplineController and UITextSplineController only// A list of events called when moving over a specific positions on the spline.

==OnEndReached== //Available for SplineController and UITextSplineController only// Called when the end (or start) of the source spline is reached ==OnSwitch== //Available for SplineController and UITextSplineController only// Called when switching between splines via the SwitchTo API method ====Advanced Settings==== ==Force Frequent Updates== By default Unity calls scripts' update less frequently in Edit mode. ForceFrequentUpdates forces this script to update in Edit mode as often as in Play mode. Most users don't need that, but that was helpful for a user working with cameras controlled by Unity in Edit mode ====Preview==== Lets you start and stop a preview of the movement in Edit Mode