Cinemachine
![]() | CinemachinePathBaseFindClosestPoint Method |
Find the closest point on the path to a given worldspace target point.
Namespace: Cinemachine
Assembly: Cinemachine (in Cinemachine.dll) Version: 2.0.0.0 (2.0.0.0)
![](SectionExpanded.png)
public virtual float FindClosestPoint( Vector3 p, int startSegment, int searchRadius, int stepsPerSegment )
function FindClosestPoint(p, startSegment, searchRadius, stepsPerSegment);
Parameters
- p
- Type: Vector3
Worldspace target that we want to approach - startSegment
- Type: SystemInt32
In what segment of the path to start the search. A Segment is a section of path between 2 waypoints. - searchRadius
- Type: SystemInt32
How many segments on either side of the startSegment to search. -1 means no limit, i.e. search the entire path - stepsPerSegment
- Type: SystemInt32
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
Return Value
Type: SingleThe position along the path that is closest to the target point. The value is in Path Units, not Distance units.
![](SectionExpanded.png)
Performance could be improved by checking the bounding polygon of each segment,
and only entering the best segment(s)
![](SectionExpanded.png)