I am new to unity and when i attack an enemy, some random enemy on the scene gets damaged.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Attack : MonoBehaviour {
public static int damage = 5;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter (Collider other){
if(other.gameObject.tag=="Enemy"){
Health.tookdamage=true;
}
}
}
when i check for the gameobject with the tag enemy, how can I refer to the one infront of me?
I have attached a script named Health and in it there is a global bool took damage. But took damage becomes true on some other enemy. How can I specify the Health Script of the enemy i hit now?