My solution to Debug Keys Challenge

private bool collisionsOn = true; // above void Start() 

 private void RespondToDebugInput() //call that from Update, OUTSIDE the if alive statement 
    {
        if (Input.GetKeyDown(KeyCode.L))
        {
            SceneManager.LoadScene(1);
        }
        
        if (Input.GetKeyDown(KeyCode.C))
        {
            if (collisionsOn)
            {
                collisionsOn = false;
            }
            else if (!collisionsOn)
            {
                collisionsOn = true;
            }
        }
    }

private void OnCollisionEnter(Collision collision)
    {
        if (state != State.Alive || !collisionsOn)
        {
            return; //stop the excecution of the method
        }

Privacy & Terms