Best way to execute a code and stop/wait for another call

Hey Guys, I’ve been asking a lot around here :stuck_out_tongue: Because I’m trying to make a wayPoint based AI. I’m getting some nice results 'til now but I want to try other way of code this.
I’m with this question since I start coding in C#. I want to know how can I execute something, like a function one time(not talking about void Start, of course) and then wait for another command to execute it again. Let’s supose I have find a wayPoint and I first want to reach it to, then, search for another. A Simple print(“Hello World”); within what I want is more than good. :smiley:

Thanks from now!
Sorry for any English mistakes, If you don’t understand what I mean, I’ll try to explain again.

I'd do it with some kind of callback. So, you have your function

void OnReachedWaypoint(Waypoint reachedThis)
{
    Debug.Log("I reached Waypoint: " + reachedThis.name);
}

(assuming that you have a type 'Waypoint' that represents a point that your AI should be approaching)

Then, where you have code that determines if the AI has reached its destination, use something like this:

if(destinationReachedThisFrame)
{
    OnReachedWaypoint(currentWaypoint);
}