I tried this but the object will not appear on the screen, what did I do wrong? My game is where you are a ball and you have to roll around to collect coins that spawn in random places.
void OnTriggerEnter(Collider collider)
{
if (collider.gameObject.name == "Player") {
Destroy(this.gameObject);
SpawnCoin();
}
}
void SpawnCoin()
{
Vector3 position = new Vector3(Random.Range(-10.0F, 10.0F), 1, Random.Range(-10.0F, 10.0F));
Instantiate(coin, position, Quaternion.identity);
}