The damage is automatically dealt to the boss and enemies with the tag “Enemy”. For example if i hit “z” 10 times the boss dies regardless if the shoots hit the boss or not. I need it to only do the damage when the shoots collide with boss.
using UnityEngine;
using System.Collections;
public class Shoot : MonoBehaviour {
public GameObject laser;
public GameObject multi;
public GameObject multiup;
public GameObject multidown;
public GameObject missile;
public GameObject melee;
public GameObject[ ] physicsGibs;
void Update ()
{
if(Input.GetKeyDown(KeyCode.Z))
{
Instantiate(laser,transform.position,transform.rotation);
GameObject Enemy = GameObject.FindWithTag(“Enemy”);
BossHealth a = Enemy.GetComponent();
a.Health -= 1f;
}
if(Input.GetKeyDown(KeyCode.X))
{
Instantiate(multi,transform.position,transform.rotation);
Instantiate(multiup,transform.position,transform.rotation);
Instantiate(multidown,transform.position,transform.rotation);
GameObject Enemy = GameObject.FindWithTag(“Enemy”);
BossHealth a = Enemy.GetComponent();
a.Health -= 1f;
}
if(Input.GetKeyDown(KeyCode.C))
{
Instantiate(missile,transform.position,transform.rotation);
GameObject Enemy = GameObject.FindWithTag(“Enemy”);
BossHealth a = Enemy.GetComponent();
a.Health -= 1f;
}
if(Input.GetKeyDown(KeyCode.LeftControl))
{
Instantiate(melee,transform.position,transform.rotation);
GameObject Enemy = GameObject.FindWithTag(“Enemy”);
BossHealth a = Enemy.GetComponent();
a.Health -= 1f;
}
}
}