private void OnCollisionStay(Collision collision)
{
if (collision.transform.tag == "Bullettag")
{
if (collision.gameObject.GetComponent<BulletScript>().playerbullet == true)
{
attackedByPlayer = true;
player = collision.gameObject.GetComponent<BulletScript>().player;
}
HP -= ((collision.gameObject.GetComponent<BulletScript>().firedamage) * (1-(fireresist/100)));
HP -= ((collision.gameObject.GetComponent<BulletScript>().icedamage) * (1 - (iceresist / 100)));
HP -= ((collision.gameObject.GetComponent<BulletScript>().ballisticdamage) * (1 - (ballisticresist / 100)));
HP -= ((collision.gameObject.GetComponent<BulletScript>().bluntdamage) * (1 - (bluntresist / 100)));
HP -= ((collision.gameObject.GetComponent<BulletScript>().chaosdamage) * (1 - (chaosresist / 100)));
HP -= ((collision.gameObject.GetComponent<BulletScript>().electricdamage) * (1 - (electricresist / 100)));
HP -= ((collision.gameObject.GetComponent<BulletScript>().normaldamage) * (1 - (normalresist / 100)));
HP -= ((collision.gameObject.GetComponent<BulletScript>().poisondamage) * (1 - (poisonresist / 100)));
HP -= ((collision.gameObject.GetComponent<BulletScript>().psychedamage) * (1 - (psycheresist / 100)));
HP -= ((collision.gameObject.GetComponent<BulletScript>().aciddamage) * (1 - (acidresist / 100)));
}
}
I have a script that’s meant to have an enemy take damage from a bullet when they’re hit by the bullet. This code works perfectly fine for individual bullets, but when I try to make a shotgun (with about 6 projectiles) the enemy is only ever hit by one bullet at a time, since its health only decrements by the damage of one bullet. How would I get around this?