Hex-Map | Perlin Noise Hex Map
kandi X-RAY | Hex-Map Summary
kandi X-RAY | Hex-Map Summary
Perlin Noise Hex Map
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Hex-Map
Hex-Map Key Features
Hex-Map Examples and Code Snippets
Community Discussions
Trending Discussions on Hex-Map
QUESTION
I am trying to instantiate some hexagons around a central hexagon but I'm getting an odd gap between some of them and I cant figure out what's causing it. The hexagons on the top and bottom should be closer to the white hexagon in the middle. I've read up on this site CatLikeCodiing on how to create hexagonal grids and the math looks right. Any ideas what the issues may be?
...ANSWER
Answered 2021-Apr-05 at 09:13The code would work as expected if your hexagons were symmetrical, meaning that rect.x == rect.y
. But your hexagons are not symmetrical, your rect.y
is slightly less that rect.x
.
The code puts the hexagons along an ideal circle around the center hexagon, and if you imagine a circle with radius rect.x * 2
and with the center in the center point, you'll see that they are definitely placed correctly.
How to fix what you get here? Well, I would rather write some new code from scratch so it could take into account the hexagons proportions. For instance, the approach of simple rotation with transform.Rotate()
by 60 degrees each won't work reliably if you won't adjust the angle and/or distance from the center point. It already have some offset, barely noticable with only one level of hexagons, but if you add another 12 hexagons around the green ones and than another 24, the gap between 2 hexagons left and right to each other will get increased more and more. On the image you already can see that there is a little gap between top-left and top-right hexagons (same with bottom-left and bottom-right), while there shouldn't be a gap, just like there's no gap between left, center and right hexagons. Yeah, it is also caused by the proportions not being taken into account.
Basically, to properly place the asymmetrical hexagons like these, you would have to place them along an ellipse instead of a circle.
Sorry for not providing code examples. Maybe all you actually need is just make the hexagons symmetrical and it will be fine already, so there's no point in trying to find a new formula.
However, here is a question about getting a point at ellipse at given angle: How to find the point on ellipse given the angle
You could use that to get a point at the ellipse at 60 degrees to place top-right hex at that position, than find a point at the ellipse at 120 degrees to place the top-left hex, and so on.
QUESTION
I am following a tutorial on Unity Hex Maps, which can be found here: hex-maps part 1
I've created a class that takes a hexgrid and allows me to set the color of a given tile. I have a public method SelectColor(int index)
to select the color.
In order to choose the color I have a panel with 4 toggles, assigned to a toggle group.
The structure looks like this:
My problem arises when I try to set the OnValueChanged method for each toggle. There are no available options to chose from, and no other objects even to access.
This is all I have available to me:
Any ideas on how to solve or address this?
EDIT (04 Nov.):
I have updated the signature of my method to SelectColorZero()
to test out if parameter-less functions would make a difference.
It did not.
There are still no methods available except MonoScript.name
EDIT (05 Nov.):
This is not a bug, this is user error. See my answer below.
...ANSWER
Answered 2019-Nov-04 at 07:25Do you have compile errors from other scripts? If so, unity won't be able to compile the scripts and you don't see your functions on the button.
You could get a refernece to your button in your script as
QUESTION
I am learning C# for unity and could use some pointers.
I am following catlikecoding hex map tutorial but I have modified the grid for my own means.
http://catlikecoding.com/unity/tutorials/hex-map-1/
My goal is to create a pyramid of squares procedurally starting from a 7 * 7 grid. I am using a prefab plane
How do I place a limit on The CreateCell
looped function so that cells with the (x,y) coordinates are not created when they meet the following expression
ANSWER
Answered 2017-Mar-28 at 16:40A quick solution would be to add an if
statement before the part of the code that creates a cell. In this case the method CreateCell()
. That if statement should have your logic in code. You would also have to create two variables for the size to check. For example:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Hex-Map
You can use Hex-Map like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page