Only switch state once, not working.

Hey,

I’ve done this before but I can’t seem to get it working this time, not sure if it’s because I’m dealing with Enums or I’ve just messed up the code.

Here’s my update()

if (transform.localScale.x > 1.1 && isCreated == false )
		{
			//Debug.Log("this is happening");
			nanoStage1States = NanoStage1States.Level2;
			isCreated = true;


			
		}

the isCreated = true, isnt sticking or something, because It’s running the NanoStage1States.Level2; continuously. I just want it to run once.

Thanks!

Hi there

Without seeing all the code its hard to guess exactly, but from what I can see you set ‘nanoStage1States’ to ‘NanoStage1States2.Level2’ in your if statement. From then in, it has the value ‘NanoStage1States2.Level2’ unless you change it elsewhere.

If you want to only run the level2 state once, you’ll need to change it to something else once it has actually run.

-Chris