How can i make an Melle Enemy do damage on contact with the player

Currently don’t have health code but all i need is some help with the Collison

Assuming you’re working in 3D, you can use this code. It assumes that you have applied the “Enemy” tag to your melee enemy:

using UnityEngine;

public class Coll : MonoBehaviour
{
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.CompareTag("Enemy"))
        {
            // your code here;
        }
    }
}

If you’re in 2D, use the OnCollision2D event instead. Apply the script to the Player and add your code for health in the marked place…

This checks to see if the object that collided with this object has the tag “Player”.

public class MelleEnemy : MonoBehaviour 
{
    public float speed;
    private Transform target;
    private int wavepointIndex = 0;
    void Start()
    {
        target = Waypoints.points[0];
    }
void Update()
{
    Vector3 dir = target.position - transform.position;
    transform.Translate(dir.normalized * speed * Time.deltaTime, Space.World);

    if (Vector3.Distance(transform.position, target.position) <= 0.4f)
    {
        GetNextWaypoint();
    }
}

void GetNextWaypoint()
{
    if (wavepointIndex >= Waypoints.points.Length - 1)
    {
        Destroy(gameObject);
        return;
    }

    wavepointIndex++;
    target = Waypoints.points[wavepointIndex];
} }

void OnTriggerEnter(Collider other) 
{
    if (other.gameObject.tag 
}