Example #1
0
        /// <summary>
        /// Set a new follow goal. (A goal that is expected to be dynamic.)
        /// </summary>
        /// <remarks>
        /// <para>
        /// This method will result in replanning.  Use <see cref="AdjustFollowGoal"/> to adjust
        /// the location of an existing follow goal.
        /// </para>
        /// <para>
        /// The goal rotation is ignored while in follow mode.
        /// </para>
        /// <para>
        /// The new 'goal event' will be triggered.  The 'at goal' event will be disabled while
        /// in follow mode.
        /// </para>
        /// </remarks>
        /// <param name="goal">The new goal.</param>
        /// <param name="goalType">The range type.</param>
        /// <returns>True if sucessful.</returns>
        public bool Follow(NavmeshPoint goal, RangeType rangeType)
        {
            goal = agent.GetPointSearch(goal);

            if (goal.polyRef == 0)
            {
                return(false);
            }

            agent.data.targetMode = agent.ChooseMoveToMode();
            agent.data.goal       = goal;
            agent.data.goalType   = rangeType;

            agent.data.flags = (agent.data.flags | NavFlag.HasNewGoal | NavFlag.GoalIsDynamic)
                               & ~NavFlag.GoalRotationEnabled;

            // Forces evaluation during next upate.
            mAtGoal = false;

            PostEvent(NavEventType.NewGoal);

            return(true);
        }