It sounds like you have Bomb hooked up to the game object incorrectly. Make sure you are assigning bomb to a living game object (something that is in the current scene). Make sure you are instantiating and/or assigning the Bomb object. Your redundancy of assigning ammo to bomb is pointless also. Maybe you wanted to instantiate a bomb instance, assign ammo to that instance, and then destroy it? Once you fix that just do GameObject.Destroy(Ammo);
Destroy (Bomb); <-- this dosent work, I get the message:
Destroying assets is permitted to avoid data loss.
GameObject.Destroy(gameObject); I have tried these variations of this:
GameObject.Destroy(Bomb);
Bomb.Destroy(gameObject);
var Bomb : GameObject;
var Ammo : GameObject;
var Stone : GameObject;
Button1()
{
Ammo = Bomb;
KillAmmo();
Instantiate (stone)
}
Button2()
{
Ammo = Stone;
KillAmmo();
Instantiate (Bomb)
}
function KillAmmo()
{
Ammo.Destroy(); <-- This is what I want to do.
}