Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

HexMapLibrary

working with hexagonal maps in Unity made easy. · By AurelWu

Scaling Hex Grid

A topic by GamerBoyAdvanced created Jun 03, 2022 Views: 231 Replies: 7
Viewing posts 1 to 3

Hello, fantastic library, been using it for a new project (Unity).
Question: Is there any support for scaling the hex grid/map?
I'm working in VR, and the 1 meter default for hex sizes is larger than I'd like.
If not, do you know if adding scaling support is possible, simple, or a nightmare?

Thanks! XD

Developer

I think all you would need to do is to add a scaling factor as parameter to most methods in  the Hexconverter Class. So if you want 50cm tiles for example, you need to multiply all the cartesian coordinates by 2 and that should do it (or more general by 100cm divided by your tile size). It's a bit late today to try it myself, but if this doesn't work please tell me and I'll see what I can do :-) . If it works it would also be nice to know it for sure. Glad you find it useful!

Developer

I was too tempted to check if it is as simple as I hoped, I didn't test it thoroughly just created a map with different scales but that worked and as hopefully everything in the library is using HexConverter to convert between tile coordinates and world/cartesian coordinates if that works everything should work. Just replace your HexConverter.cs with this here:  https://pastebin.com/eCr0kTJ4 There is a new static SetScale Method which you need to set once and then it might all just work.

This is fantastic! Thank you so much for your reply, and I'm glad it wasn't too much of a hassle. If this works, now I won't have to scale my player to be 30 meters tall! XD

I'll give it a go, and let you know my results with it :)

Hey Aurel, this worked like a charm! Now I'm able to fit the grid on a worldspace table :)

Developer

Glad to hear it was helpful and loooks intriguing. Could you be so kind and inform me when the game is released?

Hmm I can't quite say at the moment, it is a side project currently, just trying to get things together atm. But, I am glad to know you're intrigued!

One other thing I'm trying to accomplish is allowing the hex board to move it's position in worldspace, and having it respect that when using the HexConverter. Do you know if there is a simple way to allow this?
It seems to initialize the HexTiles to worldspace (0,0,0) as it stands