[solved] Collision damage and Health Controller dont work

Hey everone, Im just a beginner with unity and programming.
Here are the scripts which arn’t working:

HealthController:

public float startHealth = 5;
public int startLifePoints = 3;
private float health = 5;
private int lifePoints = 3;

private Animator anim;
private PlayerController playerController;
private bool isDead = false;
private bool isDamageable = true;

// Use this for initialization
void Start  ()
{
    anim = GetComponent<Animator>();
    playerController = GetComponent<PlayerController>();

    //der levelindex muss dem spiel entsprechend angepasst werden, wenn es eine begrüssungsszene oder eun hauptmenue gibt.
    if (Application.loadedLevel == 0)
    {
        health = startHealth;
        lifePoints = startLifePoints;
    }

    health = PlayerPrefs.GetFloat("Health");
    lifePoints = PlayerPrefs.GetInt("LifePoints");
}

void ApplyDamage (float damage)
{
    if (isDamageable)
    {
        health -= damage;

        health = Mathf.Max(0, health);

        if (!isDead)
        {
            if (health == 0)
            {
                isDead = true;
                Dying();
            }
            else
            {
                if (isDamageable)
                {
                    Damaging();
                }
            }

            isDamageable = false;
            Invoke("ResetIsDamageable", 1);
        }
    }
}

void ResetIsDamageable()
{
    isDamageable = true;
}

void Dying ()
{
    anim.SetBool("Dying", true);
    playerController.enabled = false;

    lifePoints --;

    if (lifePoints <= 0)
    {
        //start game
        Invoke("StartGame", 3);
    }
    else
    {
        // restart level
        Invoke("RestartLevel", 1);
    }
}

void StartGame()
{
    Application.LoadLevel(0);
}

void RestartLevel()
{
    health = startHealth;
    anim.SetBool("Dying", false);
    playerController.enabled = true;

    if (!playerController.lookingRight)
    {
        playerController.Flip();
    }
    // level neu generieren und spieler zurück setzen
}

void Damaging ()
{
    anim.SetTrigger("Damage");
}

void OnDestroy()
{
    PlayerPrefs.SetFloat("Health", health);
    PlayerPrefs.SetInt("LifePoints", lifePoints);
}

CollisionDamage:

public float damage = 1;

void OnTriggerEnter2D(Collider2D other)
{
    if (other.CompareTag("Player"))
    {
        other.SendMessage("ApplyDamage", damage);
    }
}

void OnTriggerStay2D(Collider2D other)
{
    if (other.CompareTag("Player"))
    {
        other.SendMessage("ApplyDamage", damage);
    }
}

}

The problem is, that the CollisionDamage-script cant use the ApplyDamage of the HealthController.
this is the error message:
SendMessage ApplyDamage has no receiver!
UnityEngine.Component:SendMessage(String, Object)
CollisionDamage:OnTriggerStay2D(Collider2D) (at Assets/Scripts/CollisionDamage.cs:20)

(these scripts are from youtube (Hummelwalker) and it works in his tutorial… :frowning: )
Thank you for your answer! :slight_smile: <3

Add this to the end of the SendMessage by default it looks for a receiver.

other.SendMessage(“ApplyDamage”, damage, SendMessageOptions.DontRequireReceiever);

I HAVE THE ANSWER!!! I just have to put the colliders of the Char on the Object with the health controller.
I’m verry happy that I know what the problem was, but now I have a other Problem:
My Char has normal long leggs, but when he pulls his legs to himself, the Collider is still in the normal position in the upper Object.
My brain is so destroyd in the momend…