Enemy AI Basic: Object reference not set to an instance of an object

Really enjoying the course but have hit a wall with Enemy AI Basic. Having the same issue that Brian_Kennedy had but in my case, I’m not sure what to do. I’ve reviewed the video a few times, I really can’t spot where I’ve gone wrong. Unit Manager is in the hierarchy:
image

Also, here’s the code from my EnemyAI script:



Any help would be greatly appreciated. Thanks so much!

The error is on line 95. From that I can see that spinAction is null. So, your enemyUnit.GetSpinAction() is not returning a spin action. Have a look and see why that is

Does that Unit have a SpinAction component attached to the game object?
Either it doesn’t have the script attached or you’re not assigning the field on the Unit script.

2 Likes

Wow, thanks so much for responding so quickly. I really appreciate it! Indeed, the SpinAction component was not attached to UnitEnemy in the hierarchy. Simple fix, everything works fine :slight_smile:

Also wanted to thank Hugo and the whole team for creating such a well crafted course and for providing this type of support. At least for me, it makes a huge difference and certainly helps to keep me motivated. Thanks again!!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms