void KillObject() { //Play a sound, if a sound clip exists if (sfx_damaged != null) { SoundManager.instance.PlaySound2DOneShot(sfx_death, 1f, true); } //Play Visual //Display visual, if a visual exists if (particalObjectWhenDamaged != null) { //Spawn a new particle object, parent it and resize GameObject po; po = Instantiate(particalObjectWhenKilled, transform.position, Quaternion.identity) as GameObject; po.transform.localScale = new Vector3(poKillSize, poKillSize, poKillSize); } //TODO convert this to an Event later, to decouple our dropScript //If the Drop Object script is attached, Drop an Object DropPickup dropScript = GetComponent <DropPickup>(); if (dropScript != null) { dropScript.RollAndDrop(); } //Disable the object, it ran out of health gameObject.SetActive(false); }
void Awake() { this.currentHealth = this.maxHealth; rb = GetComponent <Rigidbody>(); room = GetComponentInParent <Room>(); dropPickup = GetComponent <DropPickup>(); weapon = GameObject.Find("Player").GetComponentInChildren <Weapon>(); }
public void DestroyObject(GameObject objectToBeDestroyed) { dropPickup = GetComponent <DropPickup>(); dropPickup.DropItem(); Destroy(objectToBeDestroyed); }