Yebe
1
I’m making a shooter game where the player fires multiple weapons at the same time and the each weapons have different damage.
For example: PeaShooter deal 3 damage per bullet while CarrotShooter deal 5 damage per bullet.
Here’s my Enemy script if needed.
using UnityEngine;
using System.Collections;
public class EnemyStats : MonoBehaviour
{
public float enemyHealth = 30f;
private float currentHealth;
public bool enemyKilled = false;
public GameObject weapon;
private PeaShooter weaponDamage;
void Start()
{
weaponDamage = weapon.GetComponent<PeaShooter>();
}
void OnTriggerEnter(Collider other)
{
enemyHealth -= weaponDamage.ProjectileDamage;
currentHealth = enemyHealth;
if (enemyHealth <= 0f)
{
Destroy(gameObject);
}
}
}
How to make weapon other than PeaShooter deal it’s own damage to the enemy?
do i have to make another
weaponDamage = weapon.GetComponent<CarrotShooter>();
or is there other way / the correct way to do this?
You’re going to need 2 sets of variables.
One for your peashooter (you already got this) and another for your carrotshooter.
Then in your Ontrigger event tell it to deduct the damage from both weapons