NullReferenceException EnemyPathing.Move()

I’ve been trying to figure out this nullexception for the past few hours and I can get rid of it if I keep the [SerializeField] WaveConfig waveConfig in EnemyPathing and assign a wave to each Enemy prefab, but I know there’s a way to not hard code it in there like how it works in the example videos. I’m not really sure what I’m missing.

Also the NullReferenceException is called in the update as its spamming the console.
NullReferenceException: Object reference not set to an instance of an object
EnemyPathing.Move () (at Assets/Scripts/EnemyPathing.cs:37)
EnemyPathing.Update () (at Assets/Scripts/EnemyPathing.cs:22)


Hi Ally,

Welcome to our community! :slight_smile:

Please note, it’s better to copy/paste your code and apply the code fencing characters, rather than using screenshots. Screenshots are ideal for displaying specific details from within a game engine editor or even error messages, but for code, they tend to be less readable, especially on mobile devices which can require extensive zooming and scrolling.

You also prevent those that may offer to help you the ability to copy/paste part of your code back to you with suggestions and/or corrections, meaning that they would need to type a potentially lengthy response. You will often find that people are more likely to respond to your questions if you make it as easy as possible for them to do so.

NullReferenceException means that a reference (“link”) to an instance is missing. Double click on the error message to see to which line in your code it is referring. If you exposed a field in the Inspector, make sure that it’s not empty.

Hope this helps :slight_smile:


See also;

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

Privacy & Terms