This is the third time of having my cactus not be functioning properly. Every time Rick has us change something to the cactus, mine breaks.
Hi Penny,
What exactly do you mean by “mine breaks”? Doesn’t it animate anymore? Do the wrong colours appear?
In your screenshot, I can see that two SpriteRenderers are animated. Are there two SpriteRenderers attached to your Cactus? And are both supposed to be animated? If not, check your game object. What exactly do you want to animate? Animate that and remove the rest.
I fixed that part (I think) but something is still not right. I keep getting this error now. In game mode, when I click on the cactus button and click on the game screen, nothing shows up but it does take away stars from the star counter.
What does this mean:
“NullReferenceException: Object reference not set to an instance of an object
DefenderSpawner.AttemptToPlaceDefenderAt (Vector2 gridPos) (at Assets/Scripts/DefenderSpawner.cs:23)
DefenderSpawner.OnMouseDown () (at Assets/Scripts/DefenderSpawner.cs:12)
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32)”
NullReferenceException means that a reference (“link”) to an instance is missing. If you exposed a field in the Inspector, make sure that it’s not empty.
If in doubt, add a Debug.Log to the method that is supposed to spawn a defender and check whether the object you want to instantiate is assigned to the variable that you pass on to the Instantiate method.
Whew! I think I finally got my cactus fixed (crossing fingers). I had to go back and rewatch a couple of the lectures in order to fix a couple of mistakes I made when attempting to “redo” my cactus before. I sure hope it stays fixed this time.
One thing though that I couldn’t figure out is and still don’t know why: when a reference to a component (in my case it was a script) is grayed out, how do you get it to show back up? I tried to move my cactus prefab into it on the inspector and it wouldn’t let me. I tried to double-click it and it wouldn’t do anything either. Rick’s just seemed to appear and in the video, I never saw where or how he made it suddenly be there. I even checked the transcript and he never explained that. I tried to find something about it in the Unity manual but couldn’t find that specifically.
I’m glad the cactus is finally fixed.
Do you have a picture of the greyed out component? Maybe it is disabled. Or do you mean the properties in the animation? Which version of Unity do you use?
Here is a screenshot of the cactus prefab while in game mode. It won’t even start the game if I have a prefab of the cactus on the screen.
Version of Unity is 2018.3.11f1
What greyed out component do you mean? All the componends seem to be active.
That’s not the cactus prefab but a normal cactus game object. Prefabs exist in the Assets folder.
Stop the game, disable the cactus and run your game again. Does the game start now?
All is well now. I had a rough time while trying to fix the cactus and everything. My scenes got all messed up but I took a deep breath and went back to the point in the lectures where I needed to go to redo my canvases to fix my scenes and finally got everything right. Now I’m just adding more levels to the game and I will be done. Yay!!!
Well done! Sometimes it’s better to do the stuff again instead of trying to find the needle in the haystack.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.