- Home /
How should I describe to access child mesh in Java
Hi all. I have two meshes in an object and one script is attached to the parent mesh. I want to access vertices and normals of child mesh from the script attached to it's parent. I described:
var mesh : Mesh = Find.("testsphere").GetComponent(MeshFilter).mesh;
Then I got an error and it does not work at all. Someone please help me by teaching how I should describe correctly in Java Script!
Answer by Uzquiano · Apr 23, 2011 at 07:50 AM
Hi,
First, if you want to access children, maybe you are interested in: Component.GetComponentInChildren GameObject.GetComponentInChildren
Second, if you want to Find() something, you should write like this: Find.("testsphere")
And I think, it should work. And I think you already take a look to MeshFilter.mesh, but just in case
hmm...
function Update () { var mesh : $$anonymous$$esh = gameObject.GetComponentInChildren($$anonymous$$eshFilter).mesh; var normals : Vector3[] = mesh.normals;
var rotation : Quaternion = Quaternion.AngleAxis(Time.deltaTime * speed, Vector3.up);
for (var i = 0; i < normals.Length; i++)
normals[i] = rotation * normals[i];
mesh.normals = normals;
}
this still keep accessing parent mesh's normals... What's wrong with this?
Wel... what this exactly means? "Returns the component of Type type in the GameObject or any of its children using depth first search."
using depth first search? that it was first to the children? the performance doesn't say the same...
try GameObject.Find().... ins$$anonymous$$d of gameObject
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
How to destroy a parent object when child object is collided 1 Answer
Parent component affect child objects 0 Answers
How to make a child & then undo through scripting 2 Answers
How do I script a prefab like I would code a class? 1 Answer