When my weapon hit the enemy it showed this error.
I tried using Debug.Log(“Enemy health:” + enemyData.Maxhealth) at EnemyController script and yes it shows the enemy health
next I’m using Debug.Log(“Enemy take damage: ” + currentDamage) and at ProjectileWeaponBehavior script and it shows enemy take the damage. But I tried to Debug.Log(“Enemy: ” + enemy) but it showed nothing. What do I miss 🤔🤣
If the line fails to find an EnemyStats component, then the enemy variable will be empty. This is why enemy.TakeDamage() has an error, because it evaluates to null.TakeDamage().
Check that the enemy prefabs in your game all have an EnemyStats component.