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