- Home /
how to make chess board
Hi Can everyone tell me how can i make chess board..? can you give me simple code to make chess board. i am new to unity..? or can you tell me step to create chess board.....
thank
Step one: Open up Blender
Step two: $$anonymous$$ake a chessboard.
Unity is not exactly optimised for mesh creation! If you were really deter$$anonymous$$ed to make something like this, you could use unity's inbuilt cube meshes, and put them together in a grid. Then, just change the textures on every second one so that they make the traditional black-and-white pattern.
Of course, if you are talking about an entire chess game then that is a different matter entirely. That is not a question you can just ask like that, because it is complex enough that there are lots and lots of ways of doing it, each tailored for a specific use case, and there is no way of knowing from your one-and-a-half line question exactly what it is that you want to do!
Basically, I can't really answer the question, because as far as I can tell there isn't even a question to answer here.
thank you for your comment ..... now i only want to know on how to make chess board... because i am new on unity and i don't know much about unity and i want to work on it... can you tell me how to combine cube and meshes ?
thank
Just as a note, think out your questions more. For instance:
"i am new to unity..?" Is not a question ;) and:
"Can everyone tell me how can i make chess board..?" The answer to that is No... Everyone in the world could not tell you how to create a chessboard for / in unity.
I know its nit-picking, but it shows a lack of effort on your part.
Answer by timsk · Oct 14, 2011 at 10:45 AM
You don't "combine cube and meshes" a cube contains a mesh (the mesh is what makes up the cube ;)).
I would check out this post:
And also, have a look at unity's FPS and platformer tutorials, they are very detailed and walk you through a lot of core elements of unity.
Also, it sounds like you need to learn a bit more about the 3d modelling side of things (coming from the quote at the start of this answer). I would suggest 3dbuzz.com for this. Altho, if you type "3dsmax tutorial" or "maya tutorial" in google, you will get some good results. Also, it depends what 3d package you have, if you don't. Do some research on the ones available and take your pick.
Altho you don't realise it, you have summarised many questions into 1, unanswerable, vague question. Once you learn more, you will come across specific questions that people can directly answer to help you. You have to help yourself in the meantime.
@DaveA Syclamoth actually said "I can't really answer the question" ;)
Technically, neither can i. But i have attempted to point him in the right direction so that he can answer his questions himself.
Thank you so much for you advice..... i will try to do what you told me to do.... :)
Answer by tecmind · Oct 06, 2020 at 10:17 AM
Try this one: 1. Create prefabs 1x1x 0.3height for the white and black pieces; 2. Create an C# script and use the code bellow. If your code name is CreateBoard, just copy and paste bellow the class brackets; 3. Create an empty GameObject in the Hierarchy and drag the code to it; 4. In the array, use 1 for one board style or more according. Drag the white tile to the tileswhite array. Drag the black tile to the tilesBlack array. I've created an array in case you need to use diferente tile materials, but if you don't, remove the [] from the GameObject [] tilesWhite and [] tilesWhite; 5. I hope this helps you;
public class CreateBoard : MonoBehaviour { public GameObject[] tilesWhite; //If use one board design, remove the array. public GameObject[] tilesBlack;
int[] boardTiles = {1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1};
public int tilesType = 0; //Type of material of the tiles, fed in the tilesWhite/Black array;
void Start()
{
for(int r=0; r < 8; r++)
{
for(int c=0; c < 8; c++)
{
if(boardTiles[r * 8 + c] ==0)
{
Vector3 pos = new Vector3(r, 0, c);
GameObject tile = Instantiate(tilesWhite[tilesType], pos, Quaternion.identity);
}else
{
Vector3 pos = new Vector3(r, 0, c);
GameObject tile = Instantiate(tilesBlack[tilesType], pos, Quaternion.identity);
}
}
}
}
}
Answer by Scharbil · Nov 03, 2021 at 08:28 AM
Try this. In the inspector you will only need to set the number of row and collums you want for your board and the materials for each square:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CreateBoard : MonoBehaviour {
public GameObject Square0;
public GameObject Square1;
public int width;
public int height;
void Start() {
for(int r=0; r < width; r++)
{for(int c=0; c < height; c++)
{ if((r+c)%2==0){Instantiate(Square0,new Vector3(r, 0, c),Quaternion.identity);} else
if((r+c)%2==1){Instantiate(Square1,new Vector3(r, 0, c),Quaternion.identity);}
}
}
}
}
Your answer
Follow this Question
Related Questions
Why is Mathf.Pow(
iPhone Resolution Screen Switch 0 Answers
iPhone shader help to simulate TV static, works but not on iPhone. 1 Answer
Base sdk missing 1 Answer
Mini Mac - Can this Compile Unity? 2 Answers