Here below i have the simple code so when i click on a object with my left mouse button it destroy it. I have several object in my scene but I want that
I need to destroy them in a specifik order. I could give each object a tag,
the first object that needs to be destroy 1, and so… Than create an array of that, and than test in the array if that tag is the lowest of and destroy that. Any help out there to put in a code? That would be much appreciate
i changed my script a bit. Of course not each object needs to be destroy. Only the object with a tag weapon. But the rest I don’t how to do, somehow i need to give each object a value. If somebody is interested to do for like 20$ PM me.
Several ways you can do this.
Remember GameObjects can be inside other GemeObjects
so the parent Gameobject could have a tag of “weapon” and then you could put all the “actual” weapon gameobjects under that with numeric tags. But better yet. Create a basic script which you add to each weapon object and all it has is a var which is this objects Id, you can either set this in the editor manually (the id) as you add them OR create a global type static script which keeps track of the id’s and hands new ones out as weapon game objects are created.
how could create an array of the gameobjects under a gameobject, i don’t seem to find this.
Let me ask you something first. How are you creating this array of game objects? Are they added to the scene at design time or creating dynamically at runtime?
I see you have an array object in your code but its never used:
ingameobject