Oto moj problem
NullReferenceException: Object reference not set to an instance of an object
EnemyProjectile.OnTriggerEnter2D (UnityEngine.Collider2D collision) (at Assets/Scripts/EnemyProjectile.cs:20)
Oto caly skrypt
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyProjectile : MonoBehaviour
{
public float Edamage;
void OnTriggerEnter2D(Collider2D collision)
{
if (collision.tag != "Enemy")
{
if (collision.tag == "Player")
{
StatyGracza.staty.DealDamage(Edamage);
}
Destroy(gameObject);
}
}
a to drugi skrypt
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StatyGracza : MonoBehaviour
{
public static StatyGracza staty;
public GameObject Player;
public float health, Maxhealth;
void Start()
{
health = Maxhealth;
}
public void DealDamage(float damage)
{
print(damage);
health = health - damage;
CheckDeath();
}
void CheckDeath()
{
if (health <= 0)
{
Destroy(Player);
}
}
void AutoHeal()
{
if (health > Maxhealth)
{
health = Maxhealth;
}
}
}
bylbym bardzo wdzieczny za pomoc