Stop calling a function

Hey,

In my script I have a function which calls another function when the requirements are met, here:

void FixedUpdate ()
{

	if(rigidbody.velocity.magnitude > TakeOffSpeed)
		TakeOff();
	
	if(rigidbody.velocity.magnitude > TakeOffSpeed + 10)
		Balance ();	
}

What I want to happen is TakeOff() to be stopped when Balance() is called, however TakeOff() is a ‘void’ function. I have been trying to use return but I get an error, as return cannot be used on a void function!

This is TakeOff():

void TakeOff()
	{
			rigidbody.AddForce (0,50,0,ForceMode.Acceleration);
		rigidbody.AddRelativeTorque (5,0,0,ForceMode.Force);
		
	}

As you can see, I can’t use int or float, as it is a force not a value.

I’m not sure if I explained this very clearly, but help would be much appreciated :slight_smile:

Thanks

assuming this is a non static class. the simplest solution is to create a bool, and have that bool control the functionality of one, or both methods.

so it would look like this

//...
bool controlBool = false;
//...

void TakeOff(){
    if(controlBool == false){
        // other code
    }
}
void Balance(){
    controlBool = true;
    // other code
}
//...