- Home /
Creating clones, only the first clone is tagged
void Attack(){
clone = Instantiate (firePrefab, fireSpawn.position, fireSpawn.rotation) as Rigidbody;
clone.gameObject.tag = "Fire";
clone.AddForce (fireSpawn.transform.forward * fireSpeed);
}
When I fire my weapon I would like all clones have the tag "Fire" The prefab has the tag "Fire" The first clone that fires has the tag "Fire" But the rest of the clones have "Untagged"
Add debug to confirm it's this Attack and not something else, I don't see a path through that where an instaniated clone is not tagged "Fire"
Just checking -- there's a reason you can't have the prefab tagged "Fire"? Instantiate copies tags.
"Just checking -- there's a reason you can't have the prefab tagged "Fire"? Instantiate copies tags."
The prefab does have the tag "Fire" maybe i'll try and rewrite everything.... I don't know how to debug without eclipse, new to this unity thing.
Answer by Tony_T · Apr 25, 2014 at 09:58 AM
I don't know if this will help but here. This will spawn a selected game object on one of the empty game objects. Remember this will only spawn one game object at multiple spots. Like a random spawner.
#pragma strict
var source : GameObject; //The game object you want to spawn
var spawnPoints : GameObject[]; //The spawn points you want your game object to spawn
function Start ()
{
var pos : Vector3 = spawnPoints[Random.Range(0, spawnPoints.Length)].transform.position;
var instance = Instantiate(source, pos ,transform.rotation);
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613143533im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Why is the method being called every frame even though it is InvokeRepeating? 1 Answer
Prefab issue - all appear at same location 2 Answers
My script only makes two clones. 3 Answers
All subsequent instantiated objects = auto-named with suffix (Clone)? 1 Answer
Instantiate creates multiple clones. 2 Answers