12-31-2013, 10:49 AM
Okay, I figured it out with a little script which allows me to create geometries and colliders on the childs when I create a new CP :
(But if there is an other way, it would be nice to know about it )
function addMeshtoControlPoint (indexCP:int)
{
// On définit la taille du control point
transform.GetChild(indexCP).gameObject.transform.localScale = new Vector3(10,10,10);
// On ajoute le MeshFilter au child crée
transform.GetChild(indexCP).gameObject.AddComponent(MeshFilter);
// On injecte dans ce nouveau MeshFilter, le meshFilter de notre Sphere de reference
transform.GetChild(indexCP).gameObject.GetComponent(MeshFilter).mesh = sphereMeshToUse.GetComponent(MeshFilter).sharedMesh;
// On ajoute le meshCollider au child crée
transform.GetChild(indexCP).gameObject.AddComponent(MeshCollider);
// On ajoute le meshRenderer au child crée
transform.GetChild(indexCP).gameObject.AddComponent(MeshRenderer);
}
(But if there is an other way, it would be nice to know about it )
function addMeshtoControlPoint (indexCP:int)
{
// On définit la taille du control point
transform.GetChild(indexCP).gameObject.transform.localScale = new Vector3(10,10,10);
// On ajoute le MeshFilter au child crée
transform.GetChild(indexCP).gameObject.AddComponent(MeshFilter);
// On injecte dans ce nouveau MeshFilter, le meshFilter de notre Sphere de reference
transform.GetChild(indexCP).gameObject.GetComponent(MeshFilter).mesh = sphereMeshToUse.GetComponent(MeshFilter).sharedMesh;
// On ajoute le meshCollider au child crée
transform.GetChild(indexCP).gameObject.AddComponent(MeshCollider);
// On ajoute le meshRenderer au child crée
transform.GetChild(indexCP).gameObject.AddComponent(MeshRenderer);
}