I have a combato system setup as follows:
Player has a script that access the enemy script and call a TakeDamage(damage) function by doing somethign like:
public GameObject Enemy;
Enemy.GetComponent<EnemyScript>().TakeDamage(damage)
The problem is that I have different EnemyScripts (with different names), and I do not want to write a lot of similar command for each enemyscript.
Question:
Can I use an abstract class to reference the enemyscripts?
I would create an abstract class and have all the enemyscripts inherit from it. Is unity gonna be happy with me using
Enemy.GetComponent<EnemyAbstractClass>().TakeDamage(damage)
?
Im already implementing interfaces (ITakeDamage) in the enemyscripts, could I use those as a reference? Thereforre I would write something like this:
Enemy.GetComponent<ITakeDamage>().TakeDamage(damage)
?