How do I make an Object Hirarchy - I want a performant way to check if an object is an Enemy and or a specific type of enemy

Hi, I want a way to specify that an Object is a member of a Category and a subcathegory.

For example i have an Astroid that is a type of enemy, and so far it has the tag “enemy” by wich i check in one script if if it is a type of enemy, but if I now want to check in a different script if its a type of astroid I can’t simply assign a second tag wich is kind of anoying. How would i go about structuring Objects in categorys and sub cathegorys like that ?

Instead of tags, I’d recommend making use of subclassing. Have a base class called enemy, and have all enemy types inherit from it : Asteroid:Enemy, Rock:Enemy, etc…

using UnityEngine;
public class Enemy : MonoBehaviour {
		public virtual string GetType(){
			return "UNDEFINED";//Override this result.
		}
}

using UnityEngine;    	
public class Asteroid : Enemy {
		public override string GetType(){
			return "Asteroid";//
		}
}

In your game handler, where you do this checking you’d check the “Enemy”'s GetType() instead of the “GameObject”'s tag.

Here are several ways displayed as answers in how you can do this.