/// <summary> /// Trigger <see cref="OnAIInteractiveObjectDestinationReached"/> event when conditions are met. /// </summary> public void CheckIfDestinationReached(float d) { this.DeltaTime = d; if (this.IsDestinationReached()) { this.currentDestination = null; FrameWereOccuredTheLastDestinationReached = Time.frameCount; objectAgent.isStopped = true; objectAgent.ResetPath(); //Debug.Log(MyLog.Format("Destination reached !")); OnAIInteractiveObjectDestinationReached?.Invoke(); } }
public void TickDestinationReached() { //is destination reached if (CurrentDestination.HasValue) { if (!objectAgent.pathPending && objectAgent.remainingDistance <= objectAgent.stoppingDistance && (!objectAgent.hasPath || objectAgent.velocity.sqrMagnitude == 0f)) { this.currentDestination = null; FrameWereOccuredTheLastDestinationReached = Time.frameCount; objectAgent.isStopped = true; objectAgent.ResetPath(); Debug.Log(MyLog.Format("Destination reached !")); OnAIInteractiveObjectDestinationReached.Invoke(); } } }