Пример #1
0
        protected override void OnUpdateAgent()
        {
            AgentController agentController = cachedAgentController;

            if (agentController != null)
            {
                agentController.Follow(_Speed, _StoppingDistance, _Target.value);
            }
        }
Пример #2
0
        protected override void OnExecute()
        {
            AgentController agentController = cachedAgentController;

            if (agentController != null)
            {
                agentController.Follow(_Speed.value, _StoppingDistance.value, _TargetPosition.value);

                if (agentController.isDone)
                {
                    FinishExecute(true);
                }
            }
            else
            {
                FinishExecute(false);
            }
        }
        void GotoNextPoint(bool moveDone)
        {
            AgentController agentController = cachedAgentController;
            Waypoint        waypoint        = _Waypoint.value as Waypoint;

            if (waypoint == null || waypoint.pointCount == 0 || agentController == null || _IsDone)
            {
                return;
            }

            if (moveDone)
            {
                if (!_Reverse)
                {
                    _DestPoint++;
                    if (_DestPoint >= waypoint.pointCount)
                    {
                        switch (_Type)
                        {
                        case MoveWaypointType.Once:
                            Transition(_Done);
                            _IsDone    = true;
                            _DestPoint = 0;
                            return;

                        case MoveWaypointType.Cycle:
                            _DestPoint = 0;
                            break;

                        case MoveWaypointType.PingPong:
                            _DestPoint = waypoint.pointCount - 1;
                            _Reverse   = !_Reverse;
                            break;
                        }
                    }
                }
                else
                {
                    _DestPoint--;
                    if (_DestPoint < 0)
                    {
                        switch (_Type)
                        {
                        case MoveWaypointType.Once:
                            Transition(_Done);
                            _IsDone    = true;
                            _DestPoint = 0;
                            break;

                        case MoveWaypointType.Cycle:
                            _DestPoint = waypoint.pointCount - 1;
                            break;

                        case MoveWaypointType.PingPong:
                            _DestPoint = 1;
                            _Reverse   = !_Reverse;
                            break;
                        }
                    }
                }
            }

            agentController.Follow(_Speed, _StoppingDistance.value, waypoint.GetPoint(_DestPoint));
        }