Click and destroy an object in unity3d

Advertisemen

Check out our YouTube Channel - Aarlangdi dotKom for short films



Hello guys, I am here with another short tutorial.
Today, I am going to show you guys, how to click on individual object and destroy in unity3d in a easy way with very less codes.

Let's get started. First create a cube from GameObject > Create Other > Cube. Second, create javascript from Project panel, Create > Javascript and name it whatever you like then attach it in the cube you have just created and open it with your favourite script editor.

style="font-size: large;">Now type the following codes in the javascript page you have just attached in the cube.

function OnMouseDown(){
    Destroy(gameObject);
}



Thats all you need to do to click and destroy an individual object in unity.

Hope this helps...

Advertisemen

Disclaimer: Gambar, artikel ataupun video yang ada di web ini terkadang berasal dari berbagai sumber media lain. Hak Cipta sepenuhnya dipegang oleh sumber tersebut. Jika ada masalah terkait hal ini, Anda dapat menghubungi kami disini.

Tidak ada komentar:

Posting Komentar

© Copyright 2017 Tutorial Unity 3D