- Home /
GameObject positioning in World Space
I am instantiating dynamically a board with sprites (black tiles with circles). The board GameObject is set to position (0,0,0)
The sprites that are dynamically instantiated correctly are shown on the correct (desired position)
The problem is that the board is not starting from the actual bottom-left of the screen (0,0,0) but in the center of the screen as you can see from the screenshots.
How can I set the position of my Board GameObject to be at the "correct" (0,0,0) at the bottom left of the screen or set it to any position that I want?
How can I change the coordinate system of the scene so that when I set the board to (0,0,0) it will go to the bottom left of the screen?
Also how to set the corner edges of the left bottom tile (not the center of the circle) to be at the bottom left of the screen?
Thank you.
Answer by Kim-Nobre · May 06, 2019 at 06:25 PM
You need to set the "Pivot" and "Anchors" values all to 0 in the RectTransform component of the board.
I have set Pivot and Anchors of Board to 0 but nothing changed.
After changing the anchors and pivot, you also need to set the positions back to 0.
Answer by mansoor090 · May 07, 2019 at 07:48 AM
You need to set anchors like this after spawn/instantiate
gameobjectname.anchorMin = new Vector2(0, 0);
gameobjectname.anchorMax = new Vector2(0, 0);
and then set its position to zero.
I tried that but the result is the same. I also try to change the Anchors and Pivot values on run-time but it still doesn't change anything.