Class CinemachinePathBase
Abstract base class for a world-space path, suitable for a camera dolly track.
Inherited Members
Namespace: Cinemachine
Syntax
public abstract class CinemachinePathBase : MonoBehaviour
Fields
m_Appearance
The settings that control how the path will appear in the editor scene view.
Declaration
[Tooltip("The settings that control how the path will appear in the editor scene view.")]
public CinemachinePathBase.Appearance m_Appearance
Field Value
| Type | Description |
|---|---|
| CinemachinePathBase.Appearance |
m_Resolution
Path samples per waypoint
Declaration
[Tooltip("Path samples per waypoint. This is used for calculating path distances.")]
[Range(1F, 100F)]
public int m_Resolution
Field Value
| Type | Description |
|---|---|
| Int32 |
Properties
DistanceCacheSampleStepsPerSegment
When calculating the distance cache, sample the path this many times between points
Declaration
public abstract int DistanceCacheSampleStepsPerSegment { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Looped
True if the path ends are joined to form a continuous loop
Declaration
public abstract bool Looped { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
MaxPos
The maximum value for the path position
Declaration
public abstract float MaxPos { get; }
Property Value
| Type | Description |
|---|---|
| Single |
MinPos
The minimum value for the path position
Declaration
public abstract float MinPos { get; }
Property Value
| Type | Description |
|---|---|
| Single |
PathLength
Get the length of the path in distance units. If the distance cache is not valid, then calling this will trigger a potentially costly regeneration of the path distance cache
Declaration
public float PathLength { get; }
Property Value
| Type | Description |
|---|---|
| Single | The length of the path in distance units, when sampled at this rate |
Methods
DistanceCacheIsValid()
See whether the distance cache is valid. If it's not valid, then any call to GetPathLength() or ToNativePathUnits() will trigger a potentially costly regeneration of the path distance cache
Declaration
public bool DistanceCacheIsValid()
Returns
| Type | Description |
|---|---|
| Boolean | Whether the cache is valid |
EvaluateOrientation(Single)
Get the orientation the curve at a point along the path.
Declaration
public abstract Quaternion EvaluateOrientation(float pos)
Parameters
| Type | Name | Description |
|---|---|---|
| Single | pos | Postion along the path. Need not be standardized. |
Returns
| Type | Description |
|---|---|
| Quaternion | World-space orientation of the path |
EvaluateOrientationAtUnit(Single, CinemachinePathBase.PositionUnits)
Get the orientation the curve at a point along the path.
Declaration
public Quaternion EvaluateOrientationAtUnit(float pos, CinemachinePathBase.PositionUnits units)
Parameters
| Type | Name | Description |
|---|---|---|
| Single | pos | Postion along the path. Need not be normalized. |
| CinemachinePathBase.PositionUnits | units | The unit to use when interpreting the value of pos. |
Returns
| Type | Description |
|---|---|
| Quaternion | World-space orientation of the path |
EvaluatePosition(Single)
Get a worldspace position of a point along the path
Declaration
public abstract Vector3 EvaluatePosition(float pos)
Parameters
| Type | Name | Description |
|---|---|---|
| Single | pos | Postion along the path. Need not be standardized. |
Returns
| Type | Description |
|---|---|
| Vector3 | World-space position of the point along at path at pos |
EvaluatePositionAtUnit(Single, CinemachinePathBase.PositionUnits)
Get a worldspace position of a point along the path
Declaration
public Vector3 EvaluatePositionAtUnit(float pos, CinemachinePathBase.PositionUnits units)
Parameters
| Type | Name | Description |
|---|---|---|
| Single | pos | Postion along the path. Need not be normalized. |
| CinemachinePathBase.PositionUnits | units | The unit to use when interpreting the value of pos. |
Returns
| Type | Description |
|---|---|
| Vector3 | World-space position of the point along at path at pos |
EvaluateTangent(Single)
Get the tangent of the curve at a point along the path.
Declaration
public abstract Vector3 EvaluateTangent(float pos)
Parameters
| Type | Name | Description |
|---|---|---|
| Single | pos | Postion along the path. Need not be standardized. |
Returns
| Type | Description |
|---|---|
| Vector3 | World-space direction of the path tangent. Length of the vector represents the tangent strength |
EvaluateTangentAtUnit(Single, CinemachinePathBase.PositionUnits)
Get the tangent of the curve at a point along the path.
Declaration
public Vector3 EvaluateTangentAtUnit(float pos, CinemachinePathBase.PositionUnits units)
Parameters
| Type | Name | Description |
|---|---|---|
| Single | pos | Postion along the path. Need not be normalized. |
| CinemachinePathBase.PositionUnits | units | The unit to use when interpreting the value of pos. |
Returns
| Type | Description |
|---|---|
| Vector3 | World-space direction of the path tangent. Length of the vector represents the tangent strength |
FindClosestPoint(Vector3, Int32, Int32, Int32)
Find the closest point on the path to a given worldspace target point.
Declaration
public virtual float FindClosestPoint(Vector3 p, int startSegment, int searchRadius, int stepsPerSegment)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | p | Worldspace target that we want to approach |
| Int32 | startSegment | In what segment of the path to start the search. A Segment is a section of path between 2 waypoints. |
| Int32 | searchRadius | How many segments on either side of the startSegment to search. -1 means no limit, i.e. search the entire path |
| Int32 | stepsPerSegment | We search a segment by dividing it into this many straight pieces. The higher the number, the more accurate the result, but performance is proportionally slower for higher numbers |
Returns
| Type | Description |
|---|---|
| Single | The position along the path that is closest to the target point. The value is in Path Units, not Distance units. |
Remarks
Performance could be improved by checking the bounding polygon of each segment, and only entering the best segment(s)
FromPathNativeUnits(Single, CinemachinePathBase.PositionUnits)
Convert a path position from native path units to the desired units. If the distance cache is not valid, then calling this will trigger a potentially costly regeneration of the path distance cache
Declaration
public float FromPathNativeUnits(float pos, CinemachinePathBase.PositionUnits units)
Parameters
| Type | Name | Description |
|---|---|---|
| Single | pos | The value to convert from, in native units |
| CinemachinePathBase.PositionUnits | units | The units to convert to |
Returns
| Type | Description |
|---|---|
| Single | The path position, in the requested units |
InvalidateDistanceCache()
Call this if the path changes in such a way as to affect distances or other cached path elements
Declaration
public virtual void InvalidateDistanceCache()
MaxUnit(CinemachinePathBase.PositionUnits)
Get the maximum value, for the given unit type
Declaration
public float MaxUnit(CinemachinePathBase.PositionUnits units)
Parameters
| Type | Name | Description |
|---|---|---|
| CinemachinePathBase.PositionUnits | units | The unit type |
Returns
| Type | Description |
|---|---|
| Single | The maximum allowable value for this path |
MinUnit(CinemachinePathBase.PositionUnits)
Get the minimum value, for the given unit type
Declaration
public float MinUnit(CinemachinePathBase.PositionUnits units)
Parameters
| Type | Name | Description |
|---|---|---|
| CinemachinePathBase.PositionUnits | units | The unit type |
Returns
| Type | Description |
|---|---|
| Single | The minimum allowable value for this path |
StandardizePathDistance(Single)
Standardize a distance along the path based on the path length. If the distance cache is not valid, then calling this will trigger a potentially costly regeneration of the path distance cache
Declaration
public float StandardizePathDistance(float distance)
Parameters
| Type | Name | Description |
|---|---|---|
| Single | distance | The distance to standardize |
Returns
| Type | Description |
|---|---|
| Single | The standardized distance, ranging from 0 to path length |
StandardizePos(Single)
Get a standardized path position, taking spins into account if looped
Declaration
public virtual float StandardizePos(float pos)
Parameters
| Type | Name | Description |
|---|---|---|
| Single | pos | Position along the path |
Returns
| Type | Description |
|---|---|
| Single | Standardized position, between MinPos and MaxPos |
StandardizeUnit(Single, CinemachinePathBase.PositionUnits)
Standardize the unit, so that it lies between MinUmit and MaxUnit
Declaration
public virtual float StandardizeUnit(float pos, CinemachinePathBase.PositionUnits units)
Parameters
| Type | Name | Description |
|---|---|---|
| Single | pos | The value to be standardized |
| CinemachinePathBase.PositionUnits | units | The unit type |
Returns
| Type | Description |
|---|---|
| Single | The standardized value of pos, between MinUnit and MaxUnit |
ToNativePathUnits(Single, CinemachinePathBase.PositionUnits)
Get the path position to native path units. If the distance cache is not valid, then calling this will trigger a potentially costly regeneration of the path distance cache
Declaration
public float ToNativePathUnits(float pos, CinemachinePathBase.PositionUnits units)
Parameters
| Type | Name | Description |
|---|---|---|
| Single | pos | The value to convert from |
| CinemachinePathBase.PositionUnits | units | The units in which pos is expressed |
Returns
| Type | Description |
|---|---|
| Single | The path position, in native units |