I am trying to destroy all of the objects in a scene with a certain tag, but I get error using my javascript code. Anyone can help me destroy the objects with tag using javascript code? I already declared in the objects prefab as “Model1” in tag manager. Can I declared multiple prefab w/ the same tag?
I don’t know how to apply findgameobjectswithtag in this section or any better solution for it. Thank you in advance.
var objectTag = gameObject.FindGameObjectsWithTag("the objects tag");
for(var i : int = 0; i <objectTag.length; i++){
Destroy(objectTag*);*
} let me explain when accessing objects inside a tag you must create a way for it to cycle through each object, if you just state destory gameobjectwith tag then it will destroy only one, but add a simple loop then it will effect each of them. if say you only want to delete say five of ten objects then just replace length witth a number you could use this with other things as well for example heres a snippet from my code
var RagDollTag = gameObject.FindGameObjectsWithTag(“RagDoll”);*
for(var RDT : int = 0; RDT <RagDollTag.length; RDT++){*