x


on click remove

Okay, so Iv had a look at a couple of scripts but i really cant find what i want. It's quite a simple concept, you click a 3d box in the level and it disappears. I really need help with a script for this, iv already tried things like onmousedown scripts but i cant quite crack it. Can anybody please give me a snippet that would work. It would be better if it was basic, so it doesnt take you much time and i can customize it. All it needs to do is when the user clicks on a 3d object in the game, it gets deleted. Also please could you make it so that it would need to be attached to the object, rather than the camera.

Thanks in advance!

more ▼

asked Jul 04 '10 at 09:43 AM

alex 1 gravatar image

alex 1
89 13 13 19

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

1 answer: sort voted first

You can use something like this on the cube to do it:

function OnMouseDown()
{
    Destroy(gameObject);
}

The object you put the script on must have a collider (probably box collider in this case - though if you use a default unity cube, it'll have one by default)

more ▼

answered Jul 04 '10 at 09:48 AM

Mike 3 gravatar image

Mike 3
30.5k 10 65 253

Thanks a bunch, just what i needed!

Jul 04 '10 at 09:52 AM alex 1
(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:

x3003
x2087

asked: Jul 04 '10 at 09:43 AM

Seen: 1178 times

Last Updated: Jul 04 '10 at 09:43 AM