Hey! Im working on my game and i want to make the pick deletes the block by decreasing the number so heres the script that ive been working on.
var PickAxe : GameObject;
var range : float = Mathf.Infinity;
var hit : RaycastHit;
var BlockStrength = 9;
function Update ()
{
if(Input.GetButton("Fire1")){
}
if (Input.GetMouseButtonDown(1)) Erase();
}
function Erase()
{
BlockStrength --;
if (BlockStrength == 0)
if(HitBlock())
Destroy(hit.transform.gameObject);
}
function HitBlock() : boolean
{
return Physics.Raycast(transform.position, transform.forward, hit, range);
}
When i test it works! but it minus the number and minus until infinity.
Is there any ways to fix this from minus?