❔ Can someone please help me with a unity error code. Ill send part of the script.
Please.
6 Replies
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
you save your code?
I remember there was a difference in unity between
!= null
and is not null
. Is that the case here?
EnemyDestroyed
is not null, right?the only difference is that != null will return true even if the variable has a reference but the destroyed flag is set
id use
UnityEngine.Object has an implicit bool operator defined
ive tried that
ill try it again now
thank you
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.