- Home /
Destroying a specific object. C#
Hi, i need to destroy an object if a statement is true.
Im not using collider or ray on the object.
I would like to have the code on one object, and destroy another object.
The object i want to destroy is named and unique.
How do i do this?
i managed to destroy itself, but not the specific object.
The info at Script reference is very sparse and i would love any info on the function destroy :)
-Gravn
Answer by Berenger · Jul 14, 2012 at 12:28 AM
The destroy function needs the reference of an object. It can be either a GameObject or a component. To find that reference, you have a lot of ways (Find, FindWithTag, FindObjectOfType, public var assigned in the inspector, OverlapSphere etc).
You need to define clearly what trigger the destruction. A physic event, an input, time, something else ?
Your answer
Follow this Question
Related Questions
How to destroy instantiated objects. 1 Answer
Multiple Cars not working 1 Answer