Hey! im trying to do a minecraft like game. I have a script for breaking grassBlock, but i cant figureout how to make so it only breaks the grass blocks im looking at. I think i should use raycast but i dont know how to do so it detects tags. And should i have a different breakBlock script for every block or 1 script for all the block? because i want it to take different long time to break some blocks.
This is my BreakGrass script:
public int BreakTimer = 3;
public float Timer;
public float Range;
public Camera cam;
void Update ()
{
if (Input.GetMouseButton(0))
{
Timer += Time.deltaTime;
if(Timer >= BreakTimer)
{
BreakBlock();
Timer = 0;
}
}
if (Input.GetKeyUp(KeyCode.Mouse0))
{
Timer = 0;
}
}
public void BreakBlock()
{
Destroy(gameObject);
}