Pathfinding.NavMeshGraph.GetNearestForce C# (CSharp) Method

GetNearestForce() public static method

public static GetNearestForce ( NavGraph graph, INavmeshHolder navmesh, Vector3 position, NNConstraint constraint, bool accurateNearestNode ) : NNInfo
graph NavGraph
navmesh INavmeshHolder
position UnityEngine.Vector3
constraint NNConstraint
accurateNearestNode bool
return NNInfo
		public static NNInfo GetNearestForce (NavGraph graph, INavmeshHolder navmesh, Vector3 position, NNConstraint constraint, bool accurateNearestNode) {
			NNInfo nn = GetNearestForceBoth (graph, navmesh,position,constraint,accurateNearestNode);
			nn.node = nn.constrainedNode;
			nn.clampedPosition = nn.constClampedPosition;
			return nn;
		}
		

Same methods

NavMeshGraph::GetNearestForce ( Vector3 position, NNConstraint constraint ) : NNInfo

Usage Example

Ejemplo n.º 1
0
        public static NNInfo GetNearest(NavMeshGraph graph, GraphNode[] nodes, Vector3 position, NNConstraint constraint, bool accurateNearestNode)
        {
            if (nodes == null || nodes.Length == 0)
            {
                Debug.LogError("NavGraph hasn't been generated yet or does not contain any nodes");
                return(default(NNInfo));
            }
            if (constraint == null)
            {
                constraint = NNConstraint.None;
            }
            Int3[] vertices = graph.vertices;
            if (graph.bbTree == null)
            {
                return(NavMeshGraph.GetNearestForce(graph, graph, position, constraint, accurateNearestNode));
            }
            float  num    = (graph.bbTree.Size.width + graph.bbTree.Size.height) * 0.5f * 0.02f;
            NNInfo result = graph.bbTree.QueryCircle(position, num, constraint);

            if (result.node == null)
            {
                for (int i = 1; i <= 8; i++)
                {
                    result = graph.bbTree.QueryCircle(position, (float)(i * i) * num, constraint);
                    if (result.node != null || (float)((i - 1) * (i - 1)) * num > AstarPath.active.maxNearestNodeDistance * 2f)
                    {
                        break;
                    }
                }
            }
            if (result.node != null)
            {
                result.clampedPosition = NavMeshGraph.ClosestPointOnNode(result.node as TriangleMeshNode, vertices, position);
            }
            if (result.constrainedNode != null)
            {
                if (constraint.constrainDistance && ((Vector3)result.constrainedNode.position - position).sqrMagnitude > AstarPath.active.maxNearestNodeDistanceSqr)
                {
                    result.constrainedNode = null;
                }
                else
                {
                    result.constClampedPosition = NavMeshGraph.ClosestPointOnNode(result.constrainedNode as TriangleMeshNode, vertices, position);
                }
            }
            return(result);
        }
All Usage Examples Of Pathfinding.NavMeshGraph::GetNearestForce