public void setTarget(
            Vector3 worldPos,
            NavAgentMode mode,
            float targetsRadius,
            float speed,
            bool neightborAvoidance = true
            )
        {
            this.targetsRadius      = targetsRadius;
            this.neightborAvoidance = neightborAvoidance;
            this.speed = speed;

            switch (mode)
            {
            case NavAgentMode.PATH_FINDING:

                //Debug.Log("Requested path");
                isWaitingForPath = true;
                navGrid.RequestPath(
                    transform.position,
                    worldPos,
                    this.gameObject.GetInstanceID(),
                    PathCallback,
                    determinationLevel
                    );

                break;

            case NavAgentMode.DIRECT:
                this.currentTarget = worldPos;
                this.isMoving      = true;
                break;
            }
        }
Exemple #2
0
        //状态处理:根据不同的移动模式选择不同的移动计划进行移动
        //目前只有SimpleMove
        private void HandleState()
        {
            NavAgentMode target = theAgent.targetMode;

            switch (target)
            {
            case NavAgentMode.SimpleMove:
                if (mSimpleMover != mPlanner)
                {
                    TransitionState(mSimpleMover);
                }
                break;

            case NavAgentMode.CrowdMove:
                if (mCrowdMover != mPlanner)
                {
                    TransitionState(mCrowdMover);
                }
                break;
            }
        }