jrjr
New Member
Posts: 3
|
Post by jrjr on Jan 25, 2015 1:35:57 GMT
Hello there,
I'm trying to get center of a hex - I've got it adjusting raycast hit placement to the terrain height but need to center the placement also (as well as place a storage empty gameobject there.
Just looking for the routine if there is one (have looked over the code but can't seem to locate one) that can calc a hex loc or a hint or two on how to do that calculation.
thanks in advance
j
|
|
jrjr
New Member
Posts: 3
|
Post by jrjr on Jan 25, 2015 5:31:03 GMT
Oh btw Nevermind... found easier way. Good stuff!
|
|
|
Post by khash on Jan 25, 2015 10:42:06 GMT
Hey!
I'm not fully sure what calculation you are looking for but: - If you want to transform hex to world coordinates (get world center of the hex) use:
public Vector2 GetWorldPosition() in Hex class which would give you flat position. in 3d world it would be X and Z (Y is up)
to get height of the terrain you want to use: static public float GetWorldHeightAt(Vector3 world3Dposition) in world class
Does it help?
|
|
jrjr
New Member
Posts: 3
|
Post by jrjr on Jan 26, 2015 1:02:04 GMT
Yep I just had not examined code enough. Had only picked it up maybe 2 hours before asking but the conclusion i came up to was hextoworld3d as I needed to convert from vector3i back to real world to setup my stat grid.
Works excellent. Absolutely awesome product will give you a big thumbs up on Unity asset store.
|
|
|
Post by khash on Jan 26, 2015 9:03:10 GMT
Thanks! Yes you get some very handy math classes in honey to cover hopefully all transformations you would need in hexagonal space. I fully understand that this is very complex topic and not everyone loves to dig the numbers if they don't have to. Although I understand that if you spend 2 hours before finding those they are note well enough exposed, I may need to rethink the way it is arranged in the project Thanks for thumbs up!
|
|
|
Post by jrjr2 on Jan 26, 2015 12:55:40 GMT
Oh I actually meant I bought it and worked on project for 2 hrs before actually coming to point where I needed to know hex center. I only spent about 20 to 30 trying to resolve issue before asking. Generally is best pattern for me. If I bump into question after half hr search I do post and work on some other aspect until I run into what I need. I had not spent enough time looking at it. Hexto3dworld was a good definitive name - I just had 'hex center' in my head and an old unity forums post led me to believe there might not be a function for it. Thanks! Yes you get some very handy math classes in honey to cover hopefully all transformations you would need in hexagonal space. I fully understand that this is very complex topic and not everyone loves to dig the numbers if they don't have to. Although I understand that if you spend 2 hours before finding those they are note well enough exposed, I may need to rethink the way it is arranged in the project Thanks for thumbs up!
|
|
|
Post by khash on Jan 26, 2015 13:20:46 GMT
Great! Good luck with your project!
|
|