Solution - DevTools

​So I actually did the Level Skip thing like 5 - 10 videos ago because I wanted it anyway. At least until I know enough to make my own cheat menu :wink: (think Sonic 1 on the Megadrive, a dedicated interface for level skip haha)

In anticipation of this, I made my own Debug (called DevTools) script but I couldn’t figure out how to get all of the Collision stuff into it without using the Rocket.cs script. So I sloppily used a combination of the approach seen in the video and my own (mainly since I had to call my DevTools class in my Rocket class)

Anyway here is the result, I’m only pasting the relevant section from Rocket.cs and all of my DevTools. (As you can see, Level Skip is allowed for anyone, invincibility (I should have named it that haha) is only for debug builds though)

if (state != State.Alive || !DevTools.disableCol ) // Devtools = debug code
{
    return; // if not alive, leave this Method
}

public class DevTools : MonoBehaviour {

[SerializeField] int levelIndex;

public static bool disableCol = false;

// Use this for initialization
void Start ()
{
    levelIndex = SceneManager.GetActiveScene().buildIndex;
}

// Update is called once per frame
void Update ()
{
    LevelSkip();

    if (Debug.isDebugBuild)
    {
        DisableCol();
    }
}

private void LevelSkip()
{
    if (Input.GetKeyDown(KeyCode.N))
    {
        levelIndex = levelIndex + 1;

        if (levelIndex < SceneManager.sceneCountInBuildSettings)
        {
            SceneManager.LoadScene(levelIndex);
        }
        else if (levelIndex >= SceneManager.sceneCountInBuildSettings)
        {
            SceneManager.LoadScene(0);
        }
    }
}

private void DisableCol()
{
    if (Input.GetKeyDown(KeyCode.C))
    {
        disableCol = !disableCol;
    }
}
}

Privacy & Terms