In Lecture 100. WaveConfig For Path&Speed, where Rick shows us how to set wave configuration for an enemy within the EnemySpawner script, we create this enemy object which requires a wave config scriptable object the moment it’s created. However, the assignment of this scriptable object won’t happen until the next line, therefore, we would get this null reference exception in the EnemyPathing script attached to the enemy object. I thought this should the reason I was getting the exception, but WHYYYYYY, Rick had the same setup, but he wasn’t encountering any error and it worked. I looked at other posts and they didn’t help. This is really frustrating, please someone explains this to me, please.
This is the EnemySpawner script, as you can see, in line 30 we instantiate an enemy object, in the next line we assign a wave config to it. But as it runs, we get this null reference expcetion:
I looked at the EnemyPathing script:
In line 16 and line 33 it requires a wave config, but since at this moment, line 31 in EnemySpawner hasn’t been run yet, we get the null reference excpetion.