Hello !
I’m new to Unity and I must say, the community seems to be really good and active so I hope my newbie question won’t hurt anyone ![]()
I’m developing a simple game with two teams. I need to easily compare team of each GameObject to know if they are enemies.
I was considering one of the two following methods :
- Attach a script ‘TeamBehaviour’ to all my GameObject which are in a team. That way I can use GetComponent on my GameObject and call IsEnemy() in it.
- Inherit my concrete class from ‘TeamBehaviour’ and call IsEnemy() in the concrete one.
Scripts are bugging me sometimes because they seems really close to inheritance (but I get the concept when you don’t have to add multiple scripts on one GameObject). So I was wondering when do you need to attach a new script to a GameObject and when you need to make the script atteched to your GameObject inherit from another one.
If you know exactly why or if you have another method, I would really appreciate it.
It’s fuzzy in my head, I hope it’s not in the post ![]()
Thanks
It's great, thank you for your help :)
– Izina