示例#1
0
        /// <summary>
        /// Performs a raycast on the navigation mesh to perform line of sight or similar checks
        /// </summary>
        /// <param name="start">Starting point</param>
        /// <param name="end">Ending point</param>
        /// <param name="querySettings">Advanced settings to be provided to the navigation mesh query</param>
        /// <returns>The found raycast hit if <see cref="NavigationRaycastResult.Hit"/> is true</returns>
        public NavigationRaycastResult Raycast(Vector3 start, Vector3 end, NavigationQuerySettings querySettings)
        {
            NavigationRaycastResult result = new NavigationRaycastResult {
                Hit = false
            };

            if (RecastNavigationMesh == null)
            {
                return(result);
            }

            start           -= SceneOffset;
            end             -= SceneOffset;
            result           = RecastNavigationMesh.Raycast(start, end, querySettings);
            result.Position += SceneOffset;
            return(result);
        }
示例#2
0
        /// <summary>
        /// Finds a path from point <paramref cref="start"/> to <paramref cref="end"/>
        /// </summary>
        /// <param name="start">The starting location of the pathfinding query</param>
        /// <param name="end">The ending location of the pathfinding query</param>
        /// <param name="querySettings">Advanced settings to be provided to the navigation mesh query</param>
        /// <param name="path">The resulting collection of waypoints for the found path, if any (at least 2 if a path was found)</param>
        /// <returns>True if a valid path was found</returns>
        public bool TryFindPath(Vector3 start, Vector3 end, IList <Vector3> path, NavigationQuerySettings querySettings)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (RecastNavigationMesh == null)
            {
                return(false);
            }

            start -= SceneOffset;
            end   -= SceneOffset;
            if (!RecastNavigationMesh.TryFindPath(start, end, path, querySettings))
            {
                return(false);
            }

            for (int i = 0; i < path.Count; i++)
            {
                path[i] += SceneOffset;
            }
            return(true);
        }
示例#3
0
 /// <summary>
 /// Finds a path from the entity's current location to <paramref cref="end"/>
 /// </summary>
 /// <param name="end">The ending location of the pathfinding query</param>
 /// <param name="querySettings">Advanced settings to be provided to the navigation mesh query</param>
 /// <param name="path">The resulting collection of waypoints for the found path, if any (at least 2 if a path was found)</param>
 /// <returns>True if a valid path was found</returns>
 public bool TryFindPath(Vector3 end, IList <Vector3> path, NavigationQuerySettings querySettings)
 {
     return(TryFindPath(Entity.Transform.WorldMatrix.TranslationVector, end, path, querySettings));
 }
示例#4
0
 /// <summary>
 /// Performs a raycast on the navigation mesh to perform line of sight or similar checks.  Starts from the entity's current world position
 /// </summary>
 /// <param name="end">Ending point</param>
 /// <param name="querySettings">Advanced settings to be provided to the navigation mesh query</param>
 /// <returns>The found raycast hit if <see cref="NavigationRaycastResult.Hit"/> is true</returns>
 public NavigationRaycastResult Raycast(Vector3 end, NavigationQuerySettings querySettings)
 {
     return(Raycast(Entity.Transform.WorldMatrix.TranslationVector, end, querySettings));
 }