- Home /
Selecting and Rotating 3 Objects on the Game Screen
Hello, I'm making a game and I want the game to be like the description below.
Select a hexagonal group and turn them clockwise or counterclockwise. If a 3-hexagonal group of the same color occurs, they should be exploded, if not the hexagonal pieces should return to the initial state.
I added 2 C# files. I create a hexagonal grid in one. On the other I am getting the mouse click information.
void SetUp()
{
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
float yPos = j;
if(i%2 == 1)
{
yPos += yOffset;
}
GameObject hex = Instantiate(hexagons[hexToUse], new Vector2(i * xOffset, yPos), Quaternion.identity);
hex.transform.parent = this.transform;
hex.name = "(" + i * xOffset + "," + yPos + ")";
}
}
}
private void OnMouseDown()
{
firstTouchPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
}
private void OnMouseUp()
{
finalTouchPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
}
But I couldn't create the algorithm I wanted. I wish you help in this matter.
Answer by tesla54 · Sep 14, 2020 at 10:33 PM
@dogukanuraz hocam ben de 4 gundur ugrasıyorum saglıklı bir algoritma cıkaramadım.sonunda butun 3lü hexlerin orginine 111 tane point yerlestirip, her hexe tıkladığımda en yakın pointi bulup daha sonrasında da bu pointe en yakın 3 tane hexi sectirttim.ama icim rahat etmedi boyle yapınca.Hala arayis icersindeyim.
$$anonymous$$erhaba, ben de başarılı olduğunu düşündüğüm bir algoritma kuramadım. Bence yönte$$anonymous$$iz kabul edilebilir. Başarılar.
Your answer
![](https://koobas.hobune.stream/wayback/20220613011501im_/https://answers.unity.com/themes/thub/images/avi.jpg)