Node Respawn Script?

Sorta new to scripting (can read a script and understand it, but unsure of how to make one myself). I’m trying to write a script for nodes of minerals, such as Ore for mining in a game that you can gather from them.

I know I want to write something that would set the ore to be “alive” on awake, and then when it is gathered, or “killed”, destroy it, then start a respawn timer, and then when the respawn timer hits 0, make it spawn that object to a certain point again.

I figure my variables would look something like this:

var respawnTimer : float = 10;
var orePrefab : Transform;
var spawnPoint : Transform;
var oreDead : boolean = false;

… Now, I’m not sure where to start, or what it would look like, or if I’m even missing some key variables… any tips?

You could disable the collider of the ore node and hide the object until some time has expired.

You could do something like:

function OnOreDespawn() {
    renderer.enabled = false;
    collider.enabled = false;
    Invoke("OnOreRespawn", 60); // Respawn in 1 minute
}

function OnOreRespawn() {
    renderer.enabled = true;
    collider.enabled = true;       
}

But you’d need some code that calls OnOreDespawn after it has been “consumed”.