|
Hi... I have a gameobject(cube) in my scene. I want to be able to click on the gameobject and automaticaly destroy the gameobject so i wont be able to see it on my screen. What script i have to attache on my gameobject?? Thank you.
(comments are locked)
|
|
the cube should have a collider, and the script i thionk you want is when you click on the cube, it's destroyed forever. until you play the scene again. here it is:
that should work. right! also, this script goes on the object(s) you want to destory. But that will destroy the game object... Not what he clicks
Dec 03 '10 at 12:15 AM
AVividLight
@GBStudios: obviously the script goes on the object, otherwise OnMouseDown wouldn't work. So it does destroy what you click.
Dec 03 '10 at 12:17 AM
Eric5h5
Yeah, but, I was under the impression that he want to click anything... Sorry if I wasn't clear.
Dec 03 '10 at 03:54 AM
AVividLight
Thank you guys..!
Dec 03 '10 at 12:54 PM
tomeromero
(comments are locked)
|
|
Hey! I think this URL can help you http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.OnMouseDown.html Hope i helped ;)
(comments are locked)
|
|
Rather than destroying the game object, just load a scene. For example: Application.LoadLevel("Scene");
(comments are locked)
|
|
can you do the same but instead of destroying the game object it changes to another scene? Rather than destroy the object, just load the scene. For example: Application.LoadLevel("Scene");
Jun 15 '12 at 06:17 PM
poseur976
(comments are locked)
|
|
Tomeromero, This script will destroy the gameobject when you click:
And this script, will give you an idea of how to do what you asked... (I am not posting this whole script, so you can learn, and answer these questions yourself)
-Hope I helped Thank you for the script.
Dec 03 '10 at 12:53 PM
tomeromero
Sure, hope I helped!
Dec 03 '10 at 04:15 PM
AVividLight
(comments are locked)
|
