I had put the break/place block script in my engine and when i right clicked for placing a block i got a huge gaping hole in the ground, breaking blocks with the left click works fine, Can i get a little help? This is the code..
<p>var blockLayer : LayerMask = 1;
var range : float = Mathf.Infinity;
var hit : RaycastHit;</p>
<p>function Update () {
if (Input.GetMouseButtonDown(0))
Build();
if (Input.GetMouseButtonDown(1))
Erase();
}</p>
<p>function Build() {
if (HitBlock()) {
var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.transform.position = hit.transform.position + hit.normal;
}
}</p>
<p>function Erase() {
if (HitBlock())
Destroy(hit.transform.gameObject);
}</p>
<p>function HitBlock() : boolean {
return Physics.Raycast(transform.position, transform.forward, hit, range, blockLayer);
}</p>