/// <summary> /// Called on Awake /// </summary> protected override void Awake() { base.Awake(); this.WarnIfMultipleInstances(); _transform = this.transform; _wayPoints = new SimpleQueue <Vector3>(); _pathboundWayPoints = new SimpleQueue <Vector3>(); _navMessage = new UnitNavigationEventMessage(this.gameObject); _resultProcessors = this.GetComponents <SteerForPathResultProcessorComponent>(); Array.Sort(_resultProcessors, (a, b) => a.processingOrder.CompareTo(b.processingOrder)); _unit = this.GetUnitFacade(); _pathSettings = _unit.pathNavigationOptions; if (this.arrivalDistance > _pathSettings.nextNodeDistance) { Debug.LogError("The Arrival Distance must be equal to or less that the Next Node Distance."); } _stopped = true; _unit.hasArrivedAtDestination = true; }
float?ILoadBalanced.ExecuteUpdate(float deltaTime, float nextInterval) { if (this.averageActualVelocity) { _actualVelocity = (_transform.position - _lastFramePosition) / deltaTime; _lastFramePosition = _transform.position; } if (_stopped || _waiting) { return(null); } if (IsStuck(deltaTime)) { var msg = new UnitNavigationEventMessage(this.gameObject, UnitNavigationEventMessage.Event.Stuck) { destination = _unit.finalDestination.GetValueOrDefault(), pendingWaypoints = _unit.currentWaypoints.ToArray() }; Stop(); StopMovement(); GameServices.messageBus.Post(msg); return(null); } UpdateInput(); return(null); }
private void InitializeModelUnitSettings() { var pathNavOptions = _modelUnit != null ? _modelUnit.pathNavigationOptions : this[0].pathNavigationOptions; // cache locally the relevant path navigation options _replanMode = pathNavOptions.replanMode; _replanInterval = pathNavOptions.replanInterval; _nextNodeDistance = pathNavOptions.nextNodeDistance; _requestNextWaypointDistance = pathNavOptions.requestNextWaypointDistance; _navMessage = new UnitNavigationEventMessage(_modelUnit != null ? _modelUnit.gameObject : this[0].gameObject); }
/// <summary> /// Called on Awake /// </summary> protected override void Awake() { base.Awake(); this.WarnIfMultipleInstances(); _transform = this.transform; _wayPoints = new WaypointList(); _navMessage = new UnitNavigationEventMessage(this.gameObject); _resultProcessors = this.GetComponents <SteerForPathResultProcessorComponent>(); Array.Sort(_resultProcessors, (a, b) => a.processingOrder.CompareTo(b.processingOrder)); _unit = this.GetUnitFacade(); _pathSettings = _unit.pathNavigationOptions; _stopped = true; }