void Start() { sparksPrefab = (GameObject)Resources.Load("Sparks"); // link health to our on percent change handler health = GetComponent <Health>(); if (health == null) { health = PartUtil.GetComponentInParentBody <Health>(gameObject); } if (health != null) { health.onChangePercent.AddListener(OnHealthPercentChange); } materialActuators = PartUtil.GetComponentsInChildren <MaterialActuator>(gameObject); rb = GetComponent <Rigidbody>(); }
void Start() { rootGo = PartUtil.GetRootGo(gameObject); health = GetComponent <Health>(); if (health == null) { health = PartUtil.GetComponentInParentBody <Health>(gameObject); } // enforce max damage > min damage if (maxDamage < minDamage) { maxDamage = minDamage; } if (emitScrews) { screwBurstPrefab = (GameObject)Resources.Load("ScrewBurst"); } }
void Start() { joints = GetComponents <Joint>(); maxBreakForces = new float[joints.Length]; maxBreakTorques = new float[joints.Length]; // initialize max break values based on assigned values... for (var i = 0; i < joints.Length; i++) { maxBreakForces[i] = joints[i].breakForce; maxBreakTorques[i] = joints[i].breakTorque; } health = GetComponent <Health>(); if (health == null) { health = PartUtil.GetComponentInParentBody <Health>(gameObject); } if (health != null) { if (applyDamageToForce || applyDamageToTorque) { health.onChangePercent.AddListener(OnHealthPercentChange); } } }