How can I call InvokeRepeating wich can be found in the start function, after I Cancelled the Invoke?

At he moment Im making a starship game, and I making a boss battle, and when the boss comes I have to stop the InvokeRepeating wich counts the travelled distance. My problem is, when I Cancel the InvokeRepeating I can’t restart it from another function because the function belongs to the Update function.

Thank you for your help guys!

You shouldn’t have the InvokeRepeating method in the Update method. “InvokeRepeating” is constantly calling a method, so you don’t need Update to constantly tell InvokeRepeating to constantly call a method (hope that makes sense :D)

So basically you want to have a method like

public void StartCountDistanceTravelled()
{
   InvokeRepeating(CallSomeMethod);
}

public void CancelCountDistanceTravelled()
{ 
    CancelInvoke();
}

Then you can call these methods from whichever script. Use cancel to stop it, then start it when you want it to start calling that method again. If you don’t need to call these methods from another script, then make them private.