- Home /
Separate different kind of prefab/enemy ?
Hello ! I am making a game where I have different prefabs, each represent a different kind of enemy. They all have the same script to control theme, however I want a way to differenciate them. So I am making a new component script with a number. I try to get this number in my attack script but my getcomponent
if (recupgeste == "GAcircle" && recupgestescore > 0.80 || Input.GetKeyDown(KeyCode.Space))
{
transform.position = Vector3.MoveTowards(transform.position, closest2, 50 /*100*Time.deltaTime*/);
//Can't work because all the closest don't have s_FoeType_Circle script
// FoeType = closest.GetComponent<s_FoeType_Circle>().FoeType;
FoeCurrentHealth = closest.GetComponent<s_EnnemyControl>().FoeCurrentHealth;
s_EnnemyControl enemyHealth = closest.GetComponent<s_EnnemyControl>();
if (FoeCurrentHealth >0)
{
enemyHealth.TakeDamage(attackDamage);
}
}
Comment
Your answer
Follow this Question
Related Questions
Make a simple tree 1 Answer
Give prefab a parent 2 Answers
bullets kill all enemies, not just the ones hit. 1 Answer
Adding child to a instantiated prefab. 0 Answers
Destroy and Spawn an Enemy 1 Answer