I want to create a Magic Jewelry clone (Tetris + match 3) using Unity for mobile. So far, I've used UI elements such as UIImage
, which serves as an individual block. I created a script that will give out random colors for the box. I then parented three blocks to an empty game object named GameObjectParent
.
For the movement, I created another script that subtracts the GameObjectParent
's anchoredposition.y
every second. In terms of collision, I created a transparent UI Image that will serve as ground triggers that will stop the GameObjectParent
's movement once it's entered.
My problem now is the matching of the colored blocks, and more importantly, Instantiating the GameObjectParent
. I tried using out
RectTransform gRect = theCanvas.GetComponent<RectTransform>();
var groupH = Instantiate(GameObjectParent, new Vector3(0,0,0) , Quaternion.Euler(0,0,0));
groupH.transform.parent = theCanvas.transform;
groupH.transform.localScale = new Vector2(1, 1);
But it somewhat spawns out of place. I have a "startingblock" that is currently anchored on the canvas at (50, 810)
, which is where the spawned blocks should start. However, when I try this:
var groupH = Instantiate(GameObjectParent, new Vector2(80,810) , Quaternion.Euler(0,0,0));
The newly cloned and spawned GameObjectParent
goes out of place (21392,8712398)
. I don't know what's happening. Even so, if I attach the Instantiate
method on a keypress, it spawns two GameObjectParent
s at a time, the other being slightly tilted.
I also have no idea how to match the colors of the other blocks as well. I tried searching for similar game concepts like this for unity but to no avail. There are also no tutorials/guides/pointers etc. so I really have to discover it on my own. Any thoughts about this guys? And are there any pointers, guides, or anything that you could give me?
Much appreciated!