- Home /
Creating a board full of evenly spaced pieces
Creating a board should be easy but I am having a difficult time doing it in unity because of its world coordinates. I need to create a board that will have squares evenly spread out across the screen. The world coordinates aren't the only thing posing a problem though because I also want the script to have two variables that allow you to change the number of rows and columns which means that the size of the squares will have to change as well to make sure that they all fit in the screen. P.S I want this to be on mobile and in portrait mode so the resolutions will be all over the place. Any ideas on how to approach this because I am all out. If this was in pixels I would just take the screen resolution and divide it up by the number of columns and rows and add an offset but since I am new to unity I don't even know how to do this. I could really use some help with this.
Thanks in advance!
Answer by Xtro · Jul 31, 2014 at 03:51 PM
Do what you want on screen coordinates. For each object creation, convert the value you calculated for screen into world coordinate by Camera.ScreenToWorldPointSwitch
http://docs.unity3d.com/ScriptReference/Camera.ScreenToWorldPoint.html
I was trying to do ScreenToWorldPoint but failed miserably but that may be just cause I am an idiot. Could you help me find a ratio between how big the squares should be on the screen when the number of rows and columns change and whatnot?
Your answer

Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Aspect ratio for mobile games 1 Answer
How would I make a ListChangedEvent? 1 Answer
Android C# JoyStick Movement 0 Answers