Is it possible to destroy only one clone of the prefab, (I don't know it's exact name, sorry) when the player object (Sphere) hits it?
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Player")
{
Destroy (GoldCube);
}
}
The "goldCube" is the game object name, which has a prefab called "GoldCube". And I want to destroy only one clone of it, when the main object "Sphere" (tag name: "Player") hits it.
Assuming the script is on the GoldCube,
Instead of
Destroy(GoldCube);
try using
Destroy(gameObject);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If this script is on the player(which in this case, it isn't),
Destroy(other.gameObject);