Пример #1
0
        /// <summary>
        /// Moves the position from the current location to the desired location,
        /// adjusting the corridor as needed to reflect the change.
        ///
        /// Behavior:
        ///
        /// - The movement is constrained to the surface of the navigation mesh. -
        /// The corridor is automatically adjusted (shorted or lengthened) in order
        /// to remain valid. - The new position will be located in the adjusted
        /// corridor's first polygon.
        ///
        /// The expected use case is that the desired position will be 'near' the
        /// current corridor. What is considered 'near' depends on local polygon
        /// density, query search extents, etc.
        ///
        /// The resulting position will differ from the desired position if the
        /// desired position is not on the navigation mesh, or it can't be reached
        /// using a local search.
        /// </summary>
        /// <param name="npos">
        ///            The desired new position. [(x, y, z)] </param>
        /// <param name="navquery">
        ///            The query object used to build the corridor. </param>
        /// <param name="filter">
        ///            Thefilter to apply to the operation. </param>
        public virtual void movePosition(float[] npos, NavMeshQuery navquery, QueryFilter filter)
        {
            // Move along navmesh and update new position.
            MoveAlongSurfaceResult masResult = navquery.moveAlongSurface(m_path[0], m_pos, npos, filter);

            m_path = mergeCorridorStartMoved(m_path, masResult.Visited);
            // Adjust the position to stay on top of the navmesh.
            DetourCommon.vCopy(m_pos, masResult.ResultPos);
            m_pos[1] = navquery.getPolyHeight(m_path[0], masResult.ResultPos, 0, m_pos[1]);
        }
Пример #2
0
        /// <summary>
        /// Moves the target from the curent location to the desired location,
        /// adjusting the corridor as needed to reflect the change. Behavior: - The
        /// movement is constrained to the surface of the navigation mesh. - The
        /// corridor is automatically adjusted (shorted or lengthened) in order to
        /// remain valid. - The new target will be located in the adjusted corridor's
        /// last polygon.
        ///
        /// The expected use case is that the desired target will be 'near' the
        /// current corridor. What is considered 'near' depends on local polygon
        /// density, query search extents, etc. The resulting target will differ from
        /// the desired target if the desired target is not on the navigation mesh,
        /// or it can't be reached using a local search.
        /// </summary>
        /// <param name="npos">
        ///            The desired new target position. [(x, y, z)] </param>
        /// <param name="navquery">
        ///            The query object used to build the corridor. </param>
        /// <param name="filter">
        ///            The filter to apply to the operation. </param>
        public virtual void moveTargetPosition(float[] npos, NavMeshQuery navquery, QueryFilter filter)
        {
            // Move along navmesh and update new position.
            MoveAlongSurfaceResult masResult = navquery.moveAlongSurface(m_path[m_path.Count - 1], m_target, npos, filter);

            m_path = mergeCorridorEndMoved(m_path, masResult.Visited);
            // TODO: should we do that?
            // Adjust the position to stay on top of the navmesh.

            /*
             * float h = m_target[1]; navquery->getPolyHeight(m_path[m_npath-1],
             * result, &h); result[1] = h;
             */
            DetourCommon.vCopy(m_target, masResult.ResultPos);
        }