Hello.
I want to make a script that can see how much health an enemy has, depending of the prefab. This can work fine with conditions, but I don’t want to look at something ugly like this:
public int health;
GameObject name;
GameObject[] type;
void Start()
{
name = gameObject;
if(name = type[0])
{
health = 25;
}
if(name = type[1])
{
health = 35;
}
if(name = type[2])
{
health = 72;
}
if(name = type[3])
{
health = 9;
}
if(name = type[4])
{
health = 50;
}
if(name = type[5])
{
health = 1000;
}
//...and so on
}
Instead, I wanted to create something like a switch, however I can’t access the number between the square brackets with the switch, and I want to find a way to not use the method shown above. Thanks.