Arkanoid clone: How can I enable/disable colliders in my prefabs while the game runs?

I am building my own kind of Arkanoid as both a side project and a learning opportunity. In my brick prefabs, I decided to use two colliders: Mesh Colliders and Box Colliders. These bricks are not simply box-shaped; they have raised faces on both the front and back sides.

This is what the bricks look like, in a level I just designed called “DieselDucy” following the icon of a YouTube user named DieselDucy:

Since I can have over 100 bricks in a level, is there a way I can disable the Mesh Collider and enable the Box Collider by just the prefabs at runtime when the game starts? I don’t know what difference this makes performance-wise, but I think it’s easier than using a for loop to go through them and accessing the components there.

Hi @GregPDesUGD,

Of corse you can. By code you can grab the collider and enable/disable it. As you can see here.

I think you want to use it through scirpts of corse. Use GetComponent(). And then enable disable it as you want =).

If thats what you looking for, i am happy to help you.

Good luck for the solution! =)