//sets the current waypoint we are starting at public void setCurrentWaypoint(TravelWaypoint current) { if(currentWaypoint != null) currentWaypoint.active = false; currentWaypoint = current; currentWaypoint.active = true; targetWaypoint = currentWaypoint.next; }
void moveTowardsWaypoint() { transform.position = Vector2.MoveTowards(transform.position, targetWaypoint.transform.position, movementSpeed * Time.deltaTime); if (Vector2.Distance(transform.position, targetWaypoint.transform.position) < .2f) { targetWaypoint = targetWaypoint.next; if (targetWaypoint == null) { playerWon(); } } }