heres my code :
var cubeStrength : float;
var Pickaxe : GameObject;
function Update()
{
if(Input.GetMouseButtonDown(1)) Erase();
}
function Erase()
{
cubeStrength --;
if (cubeStrength == 0)
Destroy (gameObject);
}
Im trying to make the pick deletes the cube floor but the pickaxe deletes it self,is there any ways to fix this from deleting my pickaxe?
var PickAxe : GameObject;
var range : float = Mathf.Infinity;
var hit : RaycastHit;
var BlockStrength : float;
function Update ()
{
if(Input.GetButton("Fire1")){
}
if(Input.GetMouseButtonDown(0)){
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);
}
I just fixed my code but it just deletes single block.How can i make it deletes more then one block?
Consider clicking the checkmark next to the answer unless you are absolutely not satisfied with it, but I don't think you will get any more detailed anwers since there is not much to work with here.
– Unitraxx