Checking for testing mode by adding new state to the enum

Instead of introducing a new bool as per the solution I did this:

enum State { alive, transending, dead, testing }

if (Input.GetKeyDown(KeyCode.C))
{
if (state == State.alive)
state = State.testing;
else state = State.alive;

    }

void OnCollisionEnter(Collision collision)
{
if(state != State.alive){return;}

Privacy & Terms