// Find if this instance have a master in a compound collider scheme public ImpactDeformable FindMaster() { // If there is a rigidbody here then it is a physical object on its own if (GetComponent <Rigidbody>() != null) { return(null); } // A master must have impact deformable and a rigidbody Transform parent = transform.parent; while (parent != null) { ImpactDeformable master = parent.GetComponent <ImpactDeformable>(); Rigidbody masterBody = parent.GetComponent <Rigidbody>(); if ((master) && (masterBody)) { return(master); } parent = parent.parent; } return(null); }
void Awake() { // Find if this instance have a master in a compound collider scheme ImpactDeformable master = FindMaster(); if (master != null) { // Load data from master if not override flag if (!OverrideMaster) { RecalculateNormals = master.RecalculateNormals; Hardness = master.Hardness; MaxVertexMov = master.MaxVertexMov; RandomFactorDeformation = master.RandomFactorDeformation; DeformationsScale = master.DeformationsScale; DeformMeshCollider = master.DeformMeshCollider; } } // Search for a mesh filter if (MeshFilter == null) { MeshFilter = GetComponent <MeshFilter>(); } UpdateMeshFilter(); // Search for a mesh collider meshCollider = GetComponent <MeshCollider>(); InvokeRepeating("checker", 0, 0.1f); }