x


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

more ▼

asked Jul 14 '12 at 12:13 AM

Gravn gravatar image

Gravn
62 3 6 8

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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 ?

more ▼

answered Jul 14 '12 at 12:28 AM

Berenger gravatar image

Berenger
11k 12 19 53

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x4142
x1090
x764
x49
x45

asked: Jul 14 '12 at 12:13 AM

Seen: 456 times

Last Updated: Jul 14 '12 at 12:28 AM