Hi,
I'm trying to destroy an enemy object as it is touched.
I've attached a virtual button to the enemy and am using the following script (which is attached to the imagetarget rather than the virtual button as in the Soccerball example.)
This is my code:
// Called when the virtual button has just been pressed: public void OnButtonPressed(VirtualButtonBehaviour vb) { Debug.Log("OnButtonPressed"); Destroy(this.transform.parent.gameObject); }
My intention is to destroy the parent of the virtual button that has just been pressed.
Any ideas?
Hmm, sorry, virtual buttons need unique names. You should be able to reuse a name after destroying a virtual button that previously had that name, however.
You could always append a counter to the name?
- Kim