コード例 #1
0
 protected override void ClearPath()
 {
     CancelCurrentPathRequest();
     richPath.Clear();
     lastCorner               = false;
     delayUpdatePath          = false;
     distanceToSteeringTarget = float.PositiveInfinity;
 }
コード例 #2
0
        /// <summary>
        /// \copydoc Pathfinding::IAstarAI::Teleport
        ///
        /// When setting transform.position directly the agent
        /// will be clamped to the part of the navmesh it can
        /// reach, so it may not end up where you wanted it to.
        /// This ensures that the agent can move to any part of the navmesh.
        /// </summary>
        public override void Teleport(Vector3 newPosition, bool clearPath = true)
        {
            // Clamp the new position to the navmesh
            var nearest = AstarPath.active != null?AstarPath.active.GetNearest(newPosition) : new NNInfo();

            float elevation;

            movementPlane.ToPlane(newPosition, out elevation);
            newPosition = movementPlane.ToWorld(movementPlane.ToPlane(nearest.node != null ? nearest.position : newPosition), elevation);
            if (clearPath)
            {
                richPath.Clear();
            }
            base.Teleport(newPosition, clearPath);
        }
コード例 #3
0
        /** Instantly moves the agent to the target position.
         * When setting transform.position directly the agent
         * will be clamped to the part of the navmesh it can
         * reach, so it may not end up where you wanted it to.
         * This ensures that the agent can move to any part of the navmesh.
         *
         * The current path will be cleared.
         *
         * \see Works similarly to Unity's NavmeshAgent.Warp.
         */
        public void Teleport(Vector3 newPosition)
        {
            CancelCurrentPathRequest();
            // Clamp the new position to the navmesh
            var   nearest = AstarPath.active.GetNearest(newPosition);
            float elevation;

            movementPlane.ToPlane(newPosition, out elevation);
            prevPosition = tr.position = movementPlane.ToWorld(movementPlane.ToPlane(nearest.node != null ? nearest.position : newPosition), elevation);
            richPath.Clear();
            if (rvoController != null)
            {
                rvoController.Move(Vector3.zero);
            }
        }