void DamageTarget(Living target) { // damage the unit! // var damage = Random.Range (damageMin, damageMax); // target.Damage (damage, FactionManager.GetFactionType(gameObject)); // DestroyThis (); // damage the unit! //var damageInfo = ObjectManager.Instance.Obtain<DamageInfo> (); var damageInfo = new DamageInfo(); damageInfo.Value = Random.Range(damageMin, damageMax); damageInfo.SourceFactionType = FactionManager.GetFactionType(gameObject); target.Damage(damageInfo); DestroyThis(); }
//When the bullet collides with something private void OnCollisionEnter(Collision collision) { //Send a message to the Log saying Bullet hit object Debug.Log("Bullet hit object"); //Destroy the bullet object Destroy(this.gameObject); //Get the Living Script of the object Living l = collision.gameObject.GetComponent <Living>(); //If the object has a Living script if (l != null) { //Then do Damage l.Damage(Damage); } }