private void ReachedWaypoint(Waypoint waypoint) { // Add the current waypoint for processing (image capture, gcp calculation & image geotagging) waypointProcessor.AddWaypointForProcessing(waypoint); // Alert possible listeners OnWaypointReached?.Invoke(); }
private void Interacted(IInteractor interactor) { if (interactor != expectedInteractor) { return; } OnWaypointReached?.Invoke(); }
private void EnteredTrigger(IActor actor) { if (actor != expectedActor) { return; } OnWaypointReached?.Invoke(); }
private void MoveTowardsWaypoint() { //get the objects curretn position Vector3 currentPosition = this.transform.position; //get the target waypoints position Vector3 targetPosition = currentWaypoint.transform.position; //if the object isn't that close to the waypoint if (Vector3.Distance(currentPosition, targetPosition) > .1f) { //get the direction and normalize Vector3 directionOfTravel = targetPosition - currentPosition; directionOfTravel.Normalize(); //sclae the movement on each axis by the DirectonOfTravel vector this.transform.Translate( directionOfTravel.x * speed * Time.deltaTime, directionOfTravel.y * speed * Time.deltaTime, directionOfTravel.z * speed * Time.deltaTime, Space.World); } else { //if the waypoing has a pause amount then wait a bit if (currentWaypoint.waitSeconds > 0) { Pause(); Invoke("Pause", currentWaypoint.waitSeconds); } //if the current waypoint has a speed change then change it to that speed if (currentWaypoint.speedOut > 0) { speedStorage = speed; speed = currentWaypoint.speedOut; } else if (speedStorage != 0) { speed = speedStorage; speedStorage = 0; } NextWaypoint(); //Sends out event to listeners when waypoint is reached. OnWaypointReached?.Invoke(); } }
public void SusbscribeOnWaypointReached(OnWaypointReached onReached) { _wayPointReachedSubscribers += onReached; }