|
Post by bennet on Mar 17, 2015 6:58:51 GMT
Hello, I've got a list of transforms that I would like to convert to a vector3i list so I can attempt to plugin to the World.cs script. I've got a for loop set up to go thru each transform in the list but I can't figure out how to call the hexcoordinates.cs, WorldToHex(). Or how to write the conversion :blush: If anyone could please give me a brief code example of how I could do this, I would be grateful.
thanks, bennet
|
|
|
Post by khash on Mar 17, 2015 10:50:49 GMT
I think you should try HexCoordinates.GetHexCoordAt function;
Eg Vector3 position = transform.position; Vector3i hexCoord = HexCoordinates.GetHexCoordAt(position); Hex hexForTransform = World.GetInstance().hexes[hexCoord];
above code takes unity world position, finds hex coordinate from it and then asks world to give hex data under those cordinates. (note that proper code should as well check if hexes dictionary contains this item before trying to get it!)
Note that WorldToHex function is for uasge of the floating point values in HexSpace, but unlike in euclidean space you cant just "(int)floatX" to receive integer coordinates (round to exact hex), instead you have to use special process which is written for you in HexCoordinates.CustomRoundingForHexes(Vector3 pos) which converts hex floating point space to hexes.
|
|
|
Post by bennet on Mar 19, 2015 4:28:13 GMT
thanks Khash. I've got the xy to hex coords working though I may have a couple of questions for you soon could you give me a quick run down of this line please, just to clarify: Hex hexForTransform = World.GetInstance().hexes[hexCoord]; and where to look to bypass the radius creation method.. thanks again bennet
|
|
|
Post by khash on Mar 19, 2015 9:16:25 GMT
This line takes hex from dictionary of world hexes. I do not understand question about "radius creation method"
|
|