Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void Build (){
- if (HitBlock ()) {
- GameObject block = GameObject.CreatePrimitive (PrimitiveType.Cube);
- block.transform.name = "Build Block";
- block.transform.parent = buildBlocks.transform;
- block.tag = "buildBlock";
- block.AddComponent<Highlight> ();
- block.AddComponent<GlobalValues> ();
- Material newMat = new Material(Shader.Find("Legacy Shaders/Self-Illumin/Bumped Diffuse"));
- newMat.color = new Color32(148, 148, 148, 255);
- block.GetComponent<Renderer>().material = newMat;
- block.GetComponent<GlobalValues> ().i = blockType;
- newMat.mainTexture = tex ();
- Vector3 cursorPosition = hit.transform.position + hit.normal;
- block.transform.position = cursorPosition;
- blockCount++;
- lastBlocksPlaced.Add (block);
- }
- }
- public bool HitBlock() {
- Ray posRay = Camera.main.ScreenPointToRay(Input.mousePosition);
- return Physics.Raycast(posRay, out hit, Mathf.Infinity);
- }
Advertisement
Add Comment
Please, Sign In to add comment