I got these scripts here:
var blockLayer : LayerMask = 1;
var range : float = Mathf.Infinity;
var hit : RaycastHit;
function Update () {
if (Input.GetMouseButtonDown(0))
Build();
if (Input.GetMouseButtonDown(1))
Erase();
}
function Build() {
if (HitBlock()) {
var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.transform.position = hit.transform.position + hit.normal;
}
}
function Erase() {
if (HitBlock())
Destroy(hit.transform.gameObject);
}
function HitBlock() : boolean {
return Physics.Raycast(transform.position, transform.forward, hit, range, blockLayer);
}
and
for (var y = -4; y < 5; ++y)
for (var x = -4; x < 5; ++x) {
var cube : GameObject = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.transform.position = transform.position + Vector3(x, 0, y);
}
I want the player to not be able to destroy the terran such as a plane, right now it just destroys the game object. If you don’t know how to do that if I could just color the cube floor or add a picture to it as if it was a plane then that would be great too.
Sorry I am new to unity and not the best with javascript.
Please format your code using the code format button.. the button with (101/010) on its face.
– robertbu