I have a nuke Button, and what I want to happen is when I press this beautiful button, I want the enemies to all die (which it works), but I have an FX that I want to spawn at these enemy positions when they die.
I have the following script which I am stuck on…
void OnMouseDown ()
{
gameObjects = GameObject.FindGameObjectsWithTag("Enemy");
for(var i = 0 ; i < gameObjects.Length ; i ++)
{
GameObject Enemy = GameObject.Find ("Enemy");
Transform EnemyTransform = Enemy.transform;
Vector3 position = Instantiate (explosion, EnemyTransform.position,EnemyTransform.rotation) as Transform;
Destroy(gameObjects*);*
-
}*
}
}
Currently I get a The “as' operator cannot be used with a non-nullable value type
UnityEngine.Vector3’” error