How to set time to delete a block like in Minecraft?

You know how in Minecraft it takes lets say 0.5 seconds to delete a grass block, but it takes 3.5 to delete a stone block. I would like to know how to make something like that. I use C#.

1 Answer

1

Destroy has a timer parameter:

public GameObject grass:
public GameObject block;

Destroy(block, 3.5f);
Destroy(grass, 0.5f);

Is this C#? I have my blocks as prefabs how would I go about that?

@Ghosts_Riley yes it is c# code. You can drag and drop your prefab to particular game object from unity Editor.

If from the moment you are creating your prefab, you want it to live for some time only, you can add a script to the prefab with this: void Start(){ Destroy(gameObject,3.5f); }