I need someone whos good at Math

0 favourites
  • 6 posts
From the Asset Store
Setup and ready for your art, animations and story. Viral Storybook App Template.
  • So my issue is im trying to make a hexagon grid snap in game.. so ive searched and found one which works on a flat orientated hexagon... the problem is mine is pointy orientated hexagon(the point of the hexagon is at the top). so i tried googling it and tried finding formulas but i dont understand them so please can someone tell me what my formula should be..

    so the size of my hexagons are 60,70

    and the code i have found for the FLAT orientation is;

    On drag drop

    • set x to round(4*(Touch.X - 320)/(3*self.Width))
    • set y to round((Touch.Y - 280) / self.Height - self.X / 2))
    • set position to (self.Width*self.X *3/4 +320 , self.Height*(self.Y+self.X/2) + 280)

    I dont understand this at all so can someone whos good a math please tell me what my formula would be for a pointy orientated 60,70 hexagon?

    Thank you.

  • Hi,

    Perhaps I can help, but I did not understand exactly what you are aiming for. A snapshot or an example image may help.

    Correct me if I am wrong, the formula you have is of a hexagon with flat sides on top/bottom, whereas, you need a similar formula for a hexagon which is rotated 30° (which will make the hexagon's flat sides on right/left)

    Also, by 60/70 do you mean, its radius of 60 and 70 ?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Yes that is correct.

    This is an image which is similar to my hexagons except the 60,70 which i was referring too is the width and height of the object in pixels.

  • Couldn't you just flip everything?

    switch width and height in the equations. As well as the x and y's?

    So maybe this?

    On drag drop

    • set x to round((Touch.x - 280) / self.width- self.y / 2))
    • set y to round(4*(Touch.x - 320)/(3*self.height))
    • set position to (self.width*(self.x+self.y/2) + 280, self.height*self.y *3/4 +320)
  • Ye I thought it would as simple as that but it completely messed it up so I don't think it works like that unfortunately

  • Look here for everything about hexagon grids (all kinds). You should be able to do what you want refering to that.

    http://www.redblobgames.com/grids/hexagons/

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)