using UnityEngine;

public class DamageIndicator : MonoBehaviour {

    public int shrapnelLayer = 8;
    public int damageOnHit = 1;
    public int hp = 100;


	void OnCollisionEnter(Collision other) {
        if(other.gameObject.layer == shrapnelLayer) {

            Rigidbody rigidBody = other.gameObject.GetComponent<Rigidbody>();
            int damage = (int)(damageOnHit * rigidBody.velocity.magnitude * rigidBody.mass);
            hp -= damage;
            Debug.Log("HIT! Damage: " + damage);
            Destroy(other.gameObject);
        }
    }
}
