Tags/Physics Layers?

In the Brick Breaker lesson, we were taught about tags on GameObjects. Is there any reason not to use tags to define whether or not enemies can hit themselves/each other with shots instead of carefully positioning the enemy beams to appear below their own hitbox?

I mean, I know it works (that’s one of the things I used) but I’m curious if Unity tags are inherently flawed in some way (ie, they cause lag, they’re not performant, etc) or if this solution was just not chosen for the tutorial for the sake of simplicity or something. Not that it’s hard - you just modify the “if (collision.GetComponent())” if statement inside your enemy ship controller to “if (collision.GetComponent() && collision.tag != “EnemyShot”)” and make sure your enemy shot prefab has a tag.

Or… you could put things on various physics layers, then go into ‘Project Settings’, ‘Physics2D’ and make sure that the EnemyShots layer doesn’t interact with the Enemies layer, and the PlayerShots doesn’t interact with Players, and that EnemyShots doesn’t interact with PlayerShots…

It just strikes me that there’s a couple of things that seem like they’d be easier solutions than finding the exact right pixel height to create an enemy shot and hope that the lasers don’t fire.

Edit: That’s it, I’m not going to ask anything until I finish the series. Immediately after this lesson there’s a video called ‘Controlling collisions with layers’ oh jeez time to start looking ahead

1 Like

actually I thought the same things, and probably I do what I thought but in the previous lectures I learnt there is something coming up so do not mess up with things :smiley: by the way I think this course is amazing but we need another course to keep the things tidy and complete. after block breaker I bought a course on udemy it called complete and concise or something like that. It’s very good to theorical part of this.
Of course we have to try different things by ourselves and look for another instruction and a different approach. Unity official lessons are good at this and there are good youtuber guys too.

Privacy & Terms