Invert Boolean in Animator Controller using SetBool

Hi Guys.

Currently I am inverting an Animator Controller boolean parameter as follows in C#:

	private Animator ac;
	private bool DoorOpenBool = false;
	
	void Start () {
		ac=GetComponent<Animator>();
	}

	void OnMouseDown(){
		DoorOpenBool=!DoorOpenBool;
		ac.SetBool("DoorOpen", DoorOpenBool);
	}

This obviously works fine, but as a matter of curiosity, is there a way to invert the SetBool directly rather than indirectly though another Bool? For example (I’m aware that this wouldn’t work!):

	private Animator ac;
	
	void Start () {
		ac=GetComponent<Animator>();
	}

	void OnMouseDown(){
		ac.SetBool(!"DoorOpen");
	}

The only real benefit being saving typing a couple of lines of code, just a matter of curiosity really.

Thanks!

ac.SetBool("DoorOpen", !ac.GetBool("DoorOpen"));

It doesn’t just save typing 2 lines of code. It saves having the boolean stored in 2 places as well (in your first it is a field member of the class as well as a member of the animator).

Also it saves the headache of if you accidentally set one of the 2 bools out of sync with the other.

Perfect, thanks!

Animator.ToggleBool(“DoorOpen”) would be a good function to add to the API.