My take on cheat keys

I just extend it creating a different script to use on collision handler script

{

    CollisionHandler noCollision;

    public bool collisionDisabled = false;

    // Start is called before the first frame update
    void Start()
    {
       
    }

    // Update is called once per frame
    void Update()
    {
        CheatLoadLevel();
        CheatNoCollision();
    }

    void CheatLoadLevel()
    {
        if (Input.GetKeyDown(KeyCode.L))
        {
            GetComponent<CollisionHandler>().NextLevel();
        }
    }

    void CheatNoCollision()
    {
        if (Input.GetKeyDown(KeyCode.C)) 
        {
            collisionDisabled = !collisionDisabled;
        }
    }

}

then on my collsion handler script I edit it a bit with this

 {

        if (inTransition || noCollision.collisionDisabled) { return; }

        switch (collision.gameObject.tag)
        {
            case "Friendly":
                ActionToTake();
                break;
            case "Finish":
                NextLevelDelay();
                break;
            default:
                crash();
                break;
        }
    }

Privacy & Terms