each time you press the button, different enemy appear,
below is how i do it
var newenemy: Transform;
var enemy_level1: Transform;
var enemy_level2: Transform;
var enemy_level3: Transform;
//DO THE SAME FOR LEVEL 2 AND LEVEL 3 ON THE OUTSIDE
IF(PRESS BUTTON)
if(mylevel==1)
{
//IF NEW ENEMY ALREAY EXIST, YOU DESTROY IT FIRST
if(newenemy)
{
Destroy(newenemy.gameObject);
}
//THEN YOU CREATE ENEMY LEVEL 1 ON THE FLY
newenemy=Instantiate(enemy_level1,target.transform.position,Quaternion.identity);
}
else if(mylevel==2)
{
if(newanimal)
{
Destroy(newenemy.gameObject);
}
newenemy=Instantiate(enemy_level2,target.transform.position,Quaternion.identity);
}
No comments:
Post a Comment