Hey Guys Im not good at scripting but I have a Minecraft Building Script with that my Character Controller can build and destroy primitive Cubes with no textures.
So my question is if somebody could make that the blocks that I am building have textures and make a sound if I place or destroy them.
Is that possible please help Thank you for all people who help me!
Here is the Building Script:
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);
}