How do I get the enemies to damage the player?

It used to work. But then I swapped what I had for a Player to a FirstPersonController for menu reasons. Then I entered the main scene to find out that the enemies no longer damage the player.

using UnityEngine;

public class SendDamage : MonoBehaviour
{
public int damage;

private int setDamage;

private void Start()
{
    damageOutput();
}

private void damageOutput()
{
    setDamage = damage;
}
void OnCollisionStay(Collision other)
{
    if (other.transform.CompareTag("Player"))
    {
        other.transform.GetComponent<PlayerDamage>().ApplyDamage(damage);
    }

}

the Enemy SendDamage Script.

using UnityEngine;
using UnityEngine.UI;

public class PlayerDamage : MonoBehaviour
{
public Text healthPanel;
public int health = 100;

// Start is called before the first frame update
private void Start()
{
    healthPanel.text = health.ToString();
}
public void ApplyDamage(int damage)
{
    if (healthPanel != null && health > 0)
    {
        health = health - damage;
        healthPanel.text = health.ToString();
    }
}

}

and the Player Health script

I have a couple of ideas:

  • Does the new player have the “Player” tag?
  • Does the new player have the PlayerDamage-script?
  • Does the new player have a collision-hitbox (not just trigger!!)?
  • Does the new player have the collision and the PlayerDamage on the same object (not a child)?