void FollowThePathWithGroundSnap(List <Vector3> nodes) { PathFollowerUtility.FollowPathWithGroundSnap(playerObj.transform, nodes, playerSpeed, autoRotateTowardsDestination, Vector3.down, playerFloatOffset, LayerMask.NameToLayer(PathFinder.instance.graphData.groundColliderLayerName), raycastOriginOffset, raycastDistanceFromOrigin); }
void MoveTo(Vector3 position) { { PathFinder.instance.FindShortestPathOfPoints(playerObj.transform.position, position, PathFinder.instance.graphData.lineType, Execution.Asynchronously, SearchMode.Simple, delegate(List <Vector3> points) { PathFollowerUtility.StopFollowing(playerObj.transform); if (useGroundSnap) { FollowThePathWithGroundSnap(points); } else { FollowThePathNormally(points); } } ); } }
void MovePlayerToMousePosition() { //Debug.LogError(PathFinder.instance.graphData.groundColliderLayerName + " " + LayerMask.NameToLayer( PathFinder.instance.graphData.groundColliderLayerName )); LayerMask backgroundLayerMask = 1 << LayerMask.NameToLayer(PathFinder.instance.graphData.groundColliderLayerName); Ray ray = _camera.ScreenPointToRay(Input.mousePosition); RaycastHit hit; Vector3 hitPos = Vector3.zero; if (Physics.Raycast(ray, out hit, 10000f, backgroundLayerMask)) { hitPos = hit.point; } else { Debug.LogError("ERROR!"); return; } { PathFinder.instance.FindShortestPathOfPoints(playerObj.transform.position, hitPos, PathFinder.instance.graphData.lineType, Execution.Asynchronously, thoroughPathFinding ? SearchMode.Complex: SearchMode.Simple, delegate(List <Vector3> points) { PathFollowerUtility.StopFollowing(playerObj.transform); if (useGroundSnap) { FollowThePathWithGroundSnap(points); } else { FollowThePathNormally(points); } } ); } }
void FollowThePathNormally(List <Vector3> nodes) { PathFollowerUtility.FollowPath(playerObj.transform, nodes, playerSpeed); }
void FollowThePathNormally(List <Vector3> nodes) { PathFollowerUtility.FollowPath(playerObj.transform, nodes, playerSpeed, autoRotateTowardsDestination); }
/// Finds shortest path between Nodes. /// Once the path is found, it will return the path as List of Positions ( not Nodes, but vector3. If you need Nodes, use FindShortestPathOfNodes). /// <returns> Returns list of **Positions**</returns> /// <param name="startNodeID">Find the path from this node</param> /// <param name="endNodeID">Find the path to this node</param> /// <param name="pathType">Path type. It can be a straight line or curved path</param> /// <param name="executionType">Synchronous is immediate and locks the control till path is found and returns the path. /// Asynchronous type runs in coroutines with out locking the control. If you have more than 50 Nodes, Asynchronous is recommended</param> /// <param name="searchMode"> This is still WIP. For now, Intermediate and Complex does a tad bit more calculations to make the path even shorter</param> /// <param name="OnPathFound">Callback once the path is found</param> public static void FindShortestPathOfPoints(this PathFinder manager, Vector3 startPoint, Vector3 endPoint, PathLineType pathType, Execution executionType, SearchMode searchMode, System.Action <List <Vector3> > OnPathFound) { PathFollowerUtility.FindShortestPathOfPoints_Internal(manager, startPoint, endPoint, pathType, executionType, searchMode, OnPathFound); }
/// Finds shortest path between Nodes. /// Once the path is found, it will return the path as List of Positions (not Nodes, but vector3. If you need Nodes, use FindShortestPathOfNodes). /// <returns> Returns list of **Positions**</returns> /// <param name="startNodeID">Find the path from this node</param> /// <param name="endNodeID">Find the path to this node</param> /// <param name="pathType">Path type. It can be a straight line or curved path</param> /// <param name="executionType">Synchronous is immediate and locks the control till path is found and returns the path. /// Asynchronous type runs in coroutines without locking the control. If you have more than 50 Nodes, Asynchronous is recommended</param> /// <param name="OnPathFound">Callback once the path is found</param> public static void FindShortestPathOfPoints(this PathFinder manager, int startNodeID, int endNodeID, PathLineType pathType, Execution executionType, System.Action <List <Vector3> > OnPathFound) { PathFollowerUtility.FindShortestPathOfPoints_Internal(manager, startNodeID, endNodeID, pathType, executionType, OnPathFound); }