❔ Can someone please help me with a unity error code. Ill send part of the script.

Please.
6 Replies
Crispy Cable YT
Crispy Cable YTOP2y ago
NullReferenceException: Object reference not set to an instance of an object EnemySpawner.Awake () (at Assets/EnemySpawner.cs:27) Error Code private void Awake() { if (onEnemyDestroy != null) { onEnemyDestroy.AddListener(EnemyDestroyed); } 26 to 29
TheRanger
TheRanger2y ago
bigthonk you save your code?
Tvde1
Tvde12y ago
I remember there was a difference in unity between != null and is not null. Is that the case here? EnemyDestroyed is not null, right?
TheRanger
TheRanger2y ago
the only difference is that != null will return true even if the variable has a reference but the destroyed flag is set id use
if (onEnemyDestroy) {
onEnemyDestroy.AddListener(EnemyDestroyed);
if (onEnemyDestroy) {
onEnemyDestroy.AddListener(EnemyDestroyed);
UnityEngine.Object has an implicit bool operator defined
Crispy Cable YT
Crispy Cable YTOP2y ago
ive tried that ill try it again now thank you
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server