Lesson 152 Unity 2D

I have reviewed my string reference and code however I continue to get the same bug Rick gets earlier in the video. I tried to exactly replicate what he did to no avail. I find it only happens after I place a cactus, whether or not an attacker is present on the screen or not. Edit:It stops the cactus from changing from an idle animation state to an attack. Has anyone else gotten this bug/knows how to fix it.

Here it is: NullReferenceException: Object reference not set to an instance of an object
Shooter.IsAttackerInLane () (at Assets/Scripts/Shooter.cs:46)
Shooter.Update () (at Assets/Scripts/Shooter.cs:20)

Hi,

Please double click on the error message. Which line in your code gets highlighted? Is an object assigned to the myLaneSpawner variable?

I’m not entirely sure, here is whats highlighted

Make sure that the spawner and the defender have both the same y-value. Otherwise, no spawner will be assigned to myLaneSpawner in SetLaneSpawner.

Hi Nina, that seemed to be the problem thank you so much for helping me!

You’re welcome. :slight_smile:


See also:

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

Privacy & Terms