Garden Glitch Lesson 152

Hello friends! ))) Thx to u Rick and for your courses ! I have a problem with transform x and when I set parent spawner 0 0 0 my child spawners are gone out from my game . To be honest everything was fine but as Rick said in video “if you have different transform from Rick you will have null reference” as i had later. After that I messed up transform position all game objects. Please help. (((

Sorry forgot that null reference brings my to eror with line
if (myLaneSpawner.trasnform.childCount <= 0)

Hi Orxan,

Thanks for posting the line which causes the error. That’s helpful. :slight_smile:

Check where a lane gets assigned to the myLaneSpawner variable. The y-coordinates of both the defender and the spawner must be equal. Otherwise, the condition gets evaluated to false, and nothing gets assigned to myLaneSpawner. If the variable is empty, it is null, thus the NullReferenceException.

Did this help?


See also:

Hi Nina ! Thx to you as always ))). I want to check if i understand u correctly. I must return cactus prefab an lizard prefab in game cause i deleted them as Rick did. Then i must put them in a same lane ??? Sorry for dumb questions ))) i a very beginner )))

And i just remembered that after i did eveything like Rick in lesson 152 and i got null reference. I have messed transform position of game canvas game camera. I tried to set x y position as Rick had but everything got wrong. but i managed to set cactus in a write lane but lizard spawners dont match with cactus position (((

Oh Nina i ve just managed to make them y equal position. but i still have an issue with the same line of code that i mentioned and that eror for some reason tags cactus>body ((

Yes I did it i have win the null reference ))) and theres no null reference buuuut))) my cactus now is a little bit out from square . I reset body of cactus to 0 .0. 0 know i need to restore cactus position with out getting null reference ))) any suggestions ? )

Nina Hello again ))) forgive me for writting so much ))). Nina I did it all )) I have won )) Thx to you for helping me !!! The problem was that a had to remove a shooter script from cactus body )). A saw that solution in one of your topics ))) But could u be so kind to explain why i had to remove shooter script from cactus body and Rick hadnt?? ))) Thank u again Nina :grinning:

My apologise Rick doesnt have a shooter script in a cactus body ))) Thank you Nina for helping ))) You and your crew are the best ))

Good job on fixing the issue yourself, @Orxan_rzaev! :slight_smile:

The Cactus Body probably did not have the same y-position as one of the spawners. In that case, no spawner was found because our condition is: If y-position of shooter equals y-position of spawner, then assign spawner to myLaneSpawner. Without knowing much about your project, that’s just a guess, though.

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

Privacy & Terms