Quote of the Day: “Haha, that’s one of the greatest compliments I’ve ever had. lol” -Jon, on me saying one of his concept sketches looked like the cover of a metal album.
Music of the Day- A smattering of everything (To name a few- Guns N’ Roses, The Who, The Rolling Stones, Queen, and Five Finger Death Punch for some heavy metal flavor)
Today I have accomplished nothing. Not for lack of trying mind you, but I keep running into the same problem over and over again, and unlike yesterday I have no clue why it’s happening. I think I’ve clicked through the button series of “Play”->”Survival”->”Gizmo”->”Gummy Bears”->”Couch”->”Start” somewhere in the hundreds of times today. And with the exception of one of those times, I’ve received the same error message time and time again: “NullReferenceException: Object reference not set to an instance of an object-Player.InstantiateHealth () (at Assets/Scripts/Player.cs:150)” That one exception fixed the error but broke literally everything else, so back to the error it was.
Time again for the Garrett-explains-what-the-hell-that-means paragraph (Henceforth dubbed as “GEWTHTM” in this and all future posts. I’m just kidding. It’ll be the “What?” paragraph). A NullReferenceException is an error that is thrown in any programming language that basically means you’re trying to call a piece of code that either A. doesn’t exist, or B. is not currently accessible (In this case it’s B). Remember how yesterday I was trying to make data like health and powerup status save over between levels? Well, powerups were easy. Took me about 5 minutes and one line of code to get them working. Health is more complicated, but health status IS actually being transferred over. The problem is that the HUD GUI isn’t.
That was a lot of nerd words, so let me break it down. A HUD (heads-up display) shows the user- or in the case of a game, the player- any information they need to know, but in a readable manner. GUI (graphical user interface) just means that it’s being presented in a way that isn’t just a string of words. For example, instead of the bottom left corner of the screen just having a constantly updating text box that says “Player health = x”, there’s a nice-looking health bar that fills or empties based on health. it’s a lot cleaner and easier to read at a glance, plus it fits far better stylistically. It’s this thing:
See? a lot nicer to look at then a plain text readout. Back to the earlier issue: the actual value of health was being saved between levels, but the healthbar above wasn’t. And not as in it was just reset to the default value of full like it is in the picture, rather than however empty it should be, as in it ceased to exist between scenes. So that’s what I’ve spent the day trying to fix. I’ve made inklings of progress here and there, but every time I fix one error another takes its place. The one mentioned above is the one I’ve been on for the past ~4 hours. It’s one of “those” errors (Anyone who’d done computer science will understand what that means). An error where you cannot physically see why the hell it’s being thrown. Everything in the code looks fine, everything is tied together exactly as it should be, everything is being called and executed when it should be, but for some friggin’ reason one little piece breaks over and over and over and you have no clue why.
So, like much of my project so far, I go from frustrated to overjoyed and back quite often. The frustration of not being able to fix the health bar combined with the fact that Unity has been randomly crashing all day, also seemingly for no reason, is starting to really get on my nerves. However, this is all part of the process of making a game, or anything really related to computer science. I’ll fix it eventually, and when I do I’ll look back and go, “man that was so simple. Why didn’t I think of that before?” And then I will be satisfied. until then, I’m off to seethe in my frustration for a while and rack my brains for that magical solution.
If you’ve made it this far, congratulations! That’s it. No special reward today. Ha.