- Home /
Average vert normals between 2 child meshes?
How can this be done in Unity? I would do it in my modeling software, but FBX doesnt support it on export for skinned meshes. And importing the modeling software file itself still gets converted to FBX in the background of unity, so that wouldn't work. SO, how can I do this in code(unityscript)? Should be coded into a Start function right?
I am talking about having explicit normals on a object that is broken into several mesh pieces, so there are no seams between them.
Answer by Julien-Lynge · Jun 03, 2013 at 10:31 PM
Vector3 averagedNormal = (normal1 + normal2) / 2;
Thank you for the reply!!! So I would probably have to attach script to parent of the mesh peices, use GetObject to get each mesh, but then how do I assign mesh normals to normal1 and normal2 variables?
I mean, how do you assign a meshes normals to a variable?
This?
var normals : Vector3[] = mesh.normals;
But then that would use whatever mesh the script is attached to, so how could I use that in combination with GetObject? To pull in normals from child meshes?
By GetObject I assume you mean GameObject.Find()?
You would do something like this to get down to the normals:
$$anonymous$$esh mesh = GameObject.Find(Whatever).GetComponent<$$anonymous$$eshFilter>().mesh;
Vector3[] normals = mesh.normals;
Note that this is C# - you'll have to go through the examples in the script reference to get the equivalent JS calls, as I'm not a JS guy.
Your answer
![](https://koobas.hobune.stream/wayback/20220613103446im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Dynamically instantiated skinned mesh not playing animations 4 Answers
Problem drawing a mesh with Graphics.DrawMeshNow 1 Answer
Algorithm for automatic mesh creation 1 Answer
Any script to 'fix' normals/winding order? 3 Answers
Model faces arent showing up even though I reversed my normals. Anyone know what's wrong? 3 Answers