- Home /
Question by
Naserano · Apr 24, 2012 at 08:15 PM ·
destroyprogramming
When clicked on, destroy other object's script?
Hi.
Here's what I want to do:
By clicking on object -A-, destroy a specific script attached to object -B-!
I tried many ways to solve it but I couldn't since I'm not quite good when it comes to scripting. Any help please?
Comment
Best Answer
Answer by reptilebeats · Apr 24, 2012 at 08:22 PM
just send a destroy or enable in a if statement. so if i click on this then destroy(gameObject.Find("other")).getcomponent(component))
Answer by buffonomics · Apr 24, 2012 at 08:19 PM
A should have some kind of reference to B, or have a reference to something that has a reference to B or is a parent of B.
Then you can use sendMessage to B or to the parent of B that should know what to do when it receives that message, in which case, kill a child of it that is B.