If the bullet is in proximity, then take damage?

So I am well into a game, I just need to add damage to the game. I want to have a script that does the following;

  1. Check to see if the GameObject of bullet is 0.0 units away.
  2. Subtract PistolDamage(33.0f) from EnemyHealth(100.0f)
  3. When EnemyHealth is less than or equal to 0, destroy the gameobject the script is attatched to.

Hi. Can’t you use Collisions instead of check the distance?
Here a solution with OnCollisionEnter:

public float EnemyHealt = 100.0f;

public float PistolDamage = 33.0f;

void Update()

{

if (EnemyHealt <= 0)

{

Destroy(gameObject);

}

}

OnCollisionEnter(Collision Coll)

{

if (Coll.gameObject.tag == “Bullet”)

{

EnemyHealt -= PistolDamage;

Destroy(Coll.gameObject);

}

}

Be sure to add the Tag Bullet to the Bullet prefab.

float dist = Vector3.Distance(bullet.transform.position, target.transform.position);

if(dist <= 1)
{
target.health -= bullet.damage;
}

if(target.health <= 0){
Destroy(target);
}

Supposing that the enemy has a target.cs which includes a public int health and the bullet.cs includes a public int damage