Czy ktos moglby zobaczyc i powiedziec mi czemu to nie chce dzialac (nie ma zadnego errora)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyProjectile : MonoBehaviour
{
public float damage;
void OnTriggerEnter2D(Collider2D collision)
{
if (collision.name == "Player")
{
if (collision.GetComponent<GamerStats>() != null)
{
collision.GetComponent<GamerStats>().DealDamage(damage);
}
Destroy(gameObject);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GamerStats : MonoBehaviour
{
public float health, Maxhealth;
void Start()
{
health = Maxhealth;
}
public void DealDamage(float damage)
{
health -= damage;
CheckDeath();
}
void CheckDeath()
{
if (health <= 0)
{
Destroy(gameObject);
}
}
void AutoHeal()
{
if (health > Maxhealth)
{
health = Maxhealth;
}
}
}