im currently Creating a voxel game and im trying to Create torch light and so what im trying to do is when i break the torch ingame the fire prefab that gets instantiated when i place the block to also get Destroyed but i dont really have any sort of way to get the prefab that was instantiated i was thinking use collisions to see if the block had a prefab within it that way but im not 100% sure how i would go about getting it that way i also thought about useing ID’s but once again thats kinda out of my range of knowledge i would have No idea how to do that either - Thanks in Advance if anyone can give me a hand ![]()
The Instantiate function simply returns the GameObject (or other item) that was instantiated. You can use that for whatever nefarious purposes you like.
Hey thanks for the reply … bit i dont think i quiet understand ? the instantiate function i only used it to get the gameobject to where i needed it (ontop of my torch) im trying to delete it now thats the part im having issues with im not sure how to go about deleting the object once its in my scene i need it to get destroyed along with the block its instantiated onto i think i have a rough idea of what i need it to do but not quiet sure how to do it i was thinking of giving the prefab an id once their instantiated but im not quiet sure how to do that :l
You can name it uniquely by setting the .name field in code or changing the object’s name.
You can tag it uniquely in the same fashion.
Then search for name or for tag and do what you want with it.
Yes that would work but im Deleting a block and want the prefab to get deleted with it and because their will be many torches in my scene at one time im not exactly sure how to get those set names when i delete the block thats why i thought of useing collisions or something to see if their is that prefab within the block and if so then delete it but agin i have no idea how to do that ive never Coded with collisions before :S …