- Home /
The question is answered, right answer was accepted
How to detect terrain's mesh normals at given point?
Hey, quick question, how do I know the normals of a given point on the terrain, to know wich texture must be painted? (grass or cliff).
I did a quick debug code where it should detect the normals at the position of the camera, but when I move around the map the normals vector stays the same (0,1,0), even passing by mountains and stuff.
Here the code, I used terraindata.getInterpolatedNormal. Shouldn't that do it?
GUI.Label(new Rect(10,10,500,500), "Camera position: " + cameraPlayer.transform.position);
GUI.Label(new Rect(10,20,500,500), "Normals at CamPos: " + terrain.terrainData.GetInterpolatedNormal(cameraPlayer.transform.position.x, cameraPlayer.transform.position.z));
Never$$anonymous$$d! I got it working with "getSteepness". Even easier, didn't know about it.
Follow this Question
Related Questions
Procedural mesh artifacts. 1 Answer
Do Mesh Normals Influence Physics Behavior 1 Answer
Shader wants normal , but the mesh does not have them 2 Answers
How to obtain the brightness/color of a triangle? 2 Answers
Editing Terrain Topology at Runtime 0 Answers