- Home /
Creating a Procedural Grid positioning problems
I've been following along a couple of tutorials about mapping grids (for hex tilemapping etc), in particular link:here. I'm just exploring different ways of doing the same thing but have run into a positioning problem early on.
The way this tutorial works is this:
have a parent "HexGrid" object with a script which instantiates a bunch of planes in a 6x6 grid, as child objects; and
Have a Canvas which is child to the HexGrid object. The HexGrid script also instantiates a bunch of text labels in exactly the same position as the planes, to tell you the coords of each plane. These text labels are childed to the canvas
However, I'm getting a problem which I've seen time and time again and I'm wondering if there's something wrong with my Unity. Although the childed Canvas has position 0,0,0 and pivot 0.5 etc, the canvas doesn't actually sit in the right place and I have to offset it by 1.5 in x and -3 in z in order to get the labels to sit in the right place. You can see what I mean in the screenshot, where the labels don't align. The coords of the labels are precisely the same as the coords of the planes.
I found the same thing when procedurally generating a grid, using their earlier tutorial link:here. The grid was instantiated starting at 0,0,0 but in real terms it is actually out of place in scene and game view by 0.5, 0, 0.5. Its easy to fix through a hack (by just setting the parent object at 0.5, 0, 0.5) but that means that you have to add in an extra 0.5 into your code for positioning other objects that are not childed.
Can someone check (just up to the end of step 2.2 in the hex tutorial) to see if it is just me? Is there anything anyone can think of that might create this maddening problem? I assumed it was something to do with the Canvas positioning, but maybe there is a setting I don't know about?
Thanks for the help!