- Home /
Finding the height of a mesh
Hey guys,
I currently have a mesh that has vertices that move up and down to simulate water. I was wondering if I could access the height of a mesh at a specific x and z co-ordinate (preferably relative to the world, but if not I can work around it).
Thanks for your time!
Edit: I forgot to mention this, but my mesh vertices are constantly moving up and down to simulate water.
Answer by hexagonius · Jun 22, 2018 at 06:59 PM
sure. Vertices are in localspace to their MeshFilters (Transforms). if you stay axis aligned just InverseTransformPoint the position you want to check into the Transforms space and check x,y,z, whatever for the closest vertex there is. You can then TransformPoint it back into world space and you have it's z in world space.
It's getting more complicated when you're asking the height in reference to a particular direction (not axis aligned).
Yeah, I only need a world-relative height. But how would I find the height of a vertex in the first place? And can I only find the height of the nearest vertex and not a face?
You compare all vertex position. Check and see which vertex is on top - bottom = height
And unity have tranform. Inverse(local vertex) = world pos
Thanks for your answer, but how do I compare the vertex positions? And what do you mean by "top" and "bottom?"