Do or Do Not, There Is No Try

Hey friends! Today I wanted to give you an update for Martian Alchemist. The past couple weeks I’ve been working on implementing the inventory system. This seems simple enough and I originally thought it would only take me a day or two of work… Well… laughs 2.5 weeks later

First, I needed to make sure that I had the visual elements for every step of the process. I need a sprite to represent each ingredient. Then I need to make sure I have a sprite that represents what it looks like in the inventory. Then I need to make sure that I had the UI elements too: a back panel to show where it is in the inventory and text to show the quantity. This involved creating several different prefabs that would then be instantiated dynamically throughout the game (in normal words, I’m making a blueprint of what I want to be spawned at different points throughout the game).

Once I had all the elements made and imported correctly into Unity, I needed to make sure that the prefabs instantiated correctly and that all the visual elements were correct and placed where I wanted them. I made a few tweaks to the greenhouse spawning script so that there was more randomness in the spawning locations and also so that the four different seasons are taken into account (e.g. Air season should spawn more air ingredients, etc). I still need to vary the amount that you can harvest at a time (sometimes 1, sometimes as many as 5), but I will tackle that another day.

Next, I needed to ensure that visually, once you harvested the ingredient, the player knew that the ingredient was harvested. This meant destroying the instantiated game object in the greenhouse while simultaneously ensuring it showed up in the inventory.

Finally, I needed to be able to scroll through the inventory. I’m still working on this part but this one gave me a bit of trouble. Unity has a special function called ScrollRect which allows objects to be simultaneously masked and scrolled through. This is very handy for inventory and mini map systems. The problem I was facing, however, was that I was either only able to completely mask all of my ingredients in the inventory OR they were spilling over the inventory section. Neither was good lol. But luckily, after spending several hours trying to figure out what was happening, I finally got it to work! (Turns out you have to have some image on the mask—I had set the transparency to 0. Once I turned up the transparency to 1 it worked).

There’s obviously some bugs and glitches and I still need to actually enable the scrolling function, but so far, so good! Here’s a video of the latest progress.

Anyway, this was my first foray into truly unknown territory for game development as I had never implemented an inventory system before. And I’m confident I’m making a mess of my code and organization despite my best efforts to not do that lol.

But I’ve learned a couple key lessons: first, you learn best by doing. Second, you will make mistakes and that’s okay. Third, no matter how hard you try, you’ll never get it perfect the first time. And that’s okay. But don’t let the fear of imperfection or the fear of messing up stop you from trying. After all, as Master Yoda once said, “Do or do not, there is no try.”

Previous
Previous

Don’t Ever, For Any Reason, Do Anything For Anyone, For Any reason

Next
Next

Gotta Catch ‘Em All