Class CinemachinePathBase
This is a deprecated component. Use SplineContainer instead.
Inherited Members
Namespace: Unity.Cinemachine
Assembly: Unity.Cinemachine.dll
Syntax
[Obsolete("CinemachinePathBase has been deprecated. Use SplineContainer instead")]
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(1, 100)]
public int m_Resolution
Field Value
Type | Description |
---|---|
int |
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 |
---|---|
int |
Looped
True if the path ends are joined to form a continuous loop
Declaration
public abstract bool Looped { get; }
Property Value
Type | Description |
---|---|
bool |
MaxPos
The maximum value for the path position
Declaration
public abstract float MaxPos { get; }
Property Value
Type | Description |
---|---|
float |
MinPos
The minimum value for the path position
Declaration
public abstract float MinPos { get; }
Property Value
Type | Description |
---|---|
float |
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 |
---|---|
float | 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 |
---|---|
bool | Whether the cache is valid |
EvaluateLocalOrientation(float)
Get the orientation the curve at a point along the path.
Declaration
public abstract Quaternion EvaluateLocalOrientation(float pos)
Parameters
Type | Name | Description |
---|---|---|
float | pos | Postion along the path. Need not be standardized. |
Returns
Type | Description |
---|---|
Quaternion | Local-space orientation of the path |
EvaluateLocalPosition(float)
Get a local-space position of a point along the path
Declaration
public abstract Vector3 EvaluateLocalPosition(float pos)
Parameters
Type | Name | Description |
---|---|---|
float | pos | Position along the path. Need not be standardized. |
Returns
Type | Description |
---|---|
Vector3 | Local-space position of the point along at path at pos |
EvaluateLocalTangent(float)
Get the tangent of the curve at a point along the path.
Declaration
public abstract Vector3 EvaluateLocalTangent(float pos)
Parameters
Type | Name | Description |
---|---|---|
float | pos | Position along the path. Need not be standardized. |
Returns
Type | Description |
---|---|
Vector3 | Local-space direction of the path tangent. Length of the vector represents the tangent strength |
EvaluateOrientation(float)
Get the orientation the curve at a point along the path.
Declaration
public virtual Quaternion EvaluateOrientation(float pos)
Parameters
Type | Name | Description |
---|---|---|
float | pos | Postion along the path. Need not be standardized. |
Returns
Type | Description |
---|---|
Quaternion | World-space orientation of the path |
EvaluateOrientationAtUnit(float, 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 |
---|---|---|
float | 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(float)
Get a worldspace position of a point along the path
Declaration
public virtual Vector3 EvaluatePosition(float pos)
Parameters
Type | Name | Description |
---|---|---|
float | 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(float, PositionUnits)
Get a worldspace position of a point along the path
Declaration
public Vector3 EvaluatePositionAtUnit(float pos, CinemachinePathBase.PositionUnits units)
Parameters
Type | Name | Description |
---|---|---|
float | 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(float)
Get the tangent of the curve at a point along the path.
Declaration
public virtual Vector3 EvaluateTangent(float pos)
Parameters
Type | Name | Description |
---|---|---|
float | 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(float, 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 |
---|---|---|
float | 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, int, int, int)
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 |
int | startSegment | In what segment of the path to start the search. A Segment is a section of path between 2 waypoints. |
int | searchRadius | How many segments on either side of the startSegment to search. -1 means no limit, i.e. search the entire path |
int | 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 |
---|---|
float | 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(float, 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 |
---|---|---|
float | pos | The value to convert from, in native units |
CinemachinePathBase.PositionUnits | units | The units to convert to |
Returns
Type | Description |
---|---|
float | Tha 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(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 |
---|---|
float | The maximum allowable value for this path |
MinUnit(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 |
---|---|
float | The minimum allowable value for this path |
OnEnable()
Adds enable toggle to the inspector
Declaration
protected virtual void OnEnable()
StandardizePathDistance(float)
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 |
---|---|---|
float | distance | The distance to standardize |
Returns
Type | Description |
---|---|
float | The standardized distance, ranging from 0 to path length |
StandardizePos(float)
Get a standardized path position, taking spins into account if looped
Declaration
public virtual float StandardizePos(float pos)
Parameters
Type | Name | Description |
---|---|---|
float | pos | Position along the path |
Returns
Type | Description |
---|---|
float | Standardized position, between MinPos and MaxPos |
StandardizeUnit(float, 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 |
---|---|---|
float | pos | The value to be standardized |
CinemachinePathBase.PositionUnits | units | The unit type |
Returns
Type | Description |
---|---|
float | The standardized value of pos, between MinUnit and MaxUnit |
ToNativePathUnits(float, 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 |
---|---|---|
float | pos | The value to convert from |
CinemachinePathBase.PositionUnits | units | The units in which pos is expressed |
Returns
Type | Description |
---|---|
float | The path position, in native units |