Disable Box Collider?

The game I’m working on is a rage game, I’ve created an invisible block but I had no idea how to go about this. The box obviously needs a 2D collider but turning the block invisible doesn’t change the fact that the player still collides with the collider. So instead I making a smaller trigger collider underneath the block that when hit, it creates a block above it. However the problem that arose with this was I quickly found out it still doesn’t matter where the player touches the collider, it will just create the block. I then turned isTrigger off, added a rigidbody and made it kinematic. I’m at a loss of how to go about this.
Invisible Block Script:

using UnityEngine;

public class InvisibleBlock : MonoBehaviour, ITakeShellHits {
    [SerializeField] private GameObject invisibleBlock;

    private void OnCollisionEnter2D(Collision2D collision) {
        if (collision.WasHitByPlayer() && collision.HitBottom()) {
            Vector3 spawnLoc = new Vector3(transform.position.x, transform.position.y, -0.1f);
            Destroy(gameObject);
            Instantiate(invisibleBlock, spawnLoc, transform.rotation);
        }
    }

    void ITakeShellHits.HandleShellHits(ShellFlipped shell) {
        Vector3 spawnLoc = new Vector3(transform.position.x, transform.position.y, -0.1f);
        Destroy(gameObject);
        Instantiate(invisibleBlock, spawnLoc, transform.rotation);
    }
}

I’m confused as to what you want. Do you want to just disable your collider? If so do this:

GetComponent<Collider2D>().enabled = false;
3 Likes

Thankyou