My Debug Solution without disabling Landing Pad

I tried something a little bit different so, even with the collisions off, you still can go to the next level reaching the landing pad.

I also let the Debug Mode available to be toggled thru the inspector:

  [SerializeField] bool debugMode = false;

 [...]

    void Update()
    {
        if (state == State.Alive) 
        {
            RespondToThrustInput();
            RespondToRotateInput();
        }
        if (Debug.isDebugBuild)
        {
            RespondToDebugKeys();
        }
    }


    private void RespondToDebugKeys()
    {
        if (Input.GetKeyDown(KeyCode.L))
        {
            LoadNextLevel();
        }
        else if (Input.GetKeyDown(KeyCode.C))
        {
            debugMode = !debugMode;
        }
    }


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

        switch (collision.gameObject.tag)
        {
            case "Friendly":
                break;

            case "Fuel":
                print("Fuel");
                break;

            case "Finish":
                StartSuccessSequence();
                break;

            case "Dead":
                StartDeathSequence();
                break;

        }
    }



    private void StartDeathSequence()
    {
        if (debugMode) { return; }
        state = State.Dying;
        audioSource.Stop();
        audioSource.PlayOneShot(death);
        deathParticles.Play();
        Invoke("RestartGame", levelLoadDelay);
    }

Great idea allowing debug mode to be toggled in inspector, i think I might do that too.

Privacy & Terms