public void Explode() { DestructibleObj explode = GetComponent <DestructibleObj>(); explode.DestroyMech(); Destroy(gameObject); }
void Shoot() { RaycastHit hit; GameObject effectIns = Instantiate(muzzleFlash, transform.position, transform.rotation); FindObjectOfType <AudioManager>().Play("Shot1"); Destroy(effectIns, 1f); rayDelay = false; if (Physics.Raycast(Gun.transform.position, Gun.transform.forward, out hit, range)) { DestructibleObj enemy = hit.transform.GetComponent <DestructibleObj>(); if (enemy != null && enemy.tag != "Player") { damage = (int)RandomDmg(); eventLog.NewActivity(("You hit " + enemy.name + " for " + damage)); enemy.DamageIncome(damage); } if (hit.rigidbody != null) { hit.rigidbody.AddForce(-hit.normal * impactForce); } GameObject ImpactGO = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal)); Destroy(ImpactGO, 1f); } }
public void DamageOutcome(float DestroyDamage) { Collider[] collidersToDestroy = Physics.OverlapSphere(transform.position, DestroyRadius); foreach (Collider nearbyObject in collidersToDestroy) { DestructibleObj dest = nearbyObject.GetComponent <DestructibleObj>(); if (dest != null) { dest.DamageIncome(DestroyDamage); } } Collider[] collidersToMove = Physics.OverlapSphere(transform.position, DestroyRadius); foreach (Collider nearbyObject in collidersToMove) { Rigidbody rb = nearbyObject.GetComponent <Rigidbody>(); if (rb != null) { rb.AddExplosionForce(DestroyForce, transform.position, DestroyRadius); } } }
void Start() { GameObject pathNode = new GameObject(); pathNode.transform.position = this.transform.position; GetComponent <Rigidbody>().centerOfMass = CenterOfMass; //Transform[] PathTransforms = Path.GetComponentsInChildren<Transform>(); CarHealth = GetComponent <DestructibleObj>(); Score = 0; ScoreText.text = ""; CurrLine = Line1; WheelFL.motorTorque = 0; WheelFR.motorTorque = 0; //Nodes = new List<Transform>(); //for (int i = 0; i < PathTransforms.Length; i++) // if(PathTransforms[i] != Path.transform) // { // Nodes.Add(PathTransforms[i]); // } }