LazyBot/Assets/Scripts/Navigation/NavigationContainer.cs
/// <summary>
/// Search for the nearest navigation point.
/// </summary>
/// <param name="destination">Relative index of nearest navigation point, updates after finding nearest point.</param>
/// <returns>Position in scene.</returns>
Search for the nearest navigation point.
Search for the nearest navigation point .
public Vector3 GetNearestPoint(ref int destination)
        {
            if (Points.Count == 0)
                throw new System.Exception("Can't get nearest point position, navigation is empty.");
            float distanceMin = int.MaxValue;
            float distanceTemp = 0.0f;
            for (int i = 0; i < Points.Count; i++)
            {
                distanceTemp = Vector3.Distance(_ownerTransform.position,
                    Points[i].Transform.position);
                if (distanceTemp < distanceMin)
                {
                    distanceMin = distanceTemp;
                    destination = i;
                }
            }
            _previousPoint = destination;
            _destinationPoint = (_previousPoint + 1) % Points.Count;
            return Points[destination].Transform.position;
        }
public Vector3 GetNearestPoint ( ref int destination ) { if ( Points . Count == 0 ) throw new System . Exception ( " " ) ; float distanceMin = int . MaxValue ; float distanceTemp = 0.0f ; for ( int i = 0 ; i < Points . Count ; i ++ ) { distanceTemp = Vector3 . Distance ( _ownerTransform . position , Points [ i ] . Transform . position ) ; if ( distanceTemp < distanceMin ) { distanceMin = distanceTemp ; destination = i ; } } _previousPoint = destination ; _destinationPoint = ( _previousPoint + 1 ) % Points . Count ; return Points [ destination ] . Transform . position ; }
Search for the nearest navigation point.
Search for the nearest navigation point .
Position in scene.
Position in scene .
int
ref
destination
Relative index of nearest navigation point, updates after finding nearest point.
Relative index of nearest navigation point updates after finding nearest point .