Ball Box - Week 2
- Jason Warrick
- Jun 16, 2022
- 3 min read
Updated: Jul 17, 2022
Following the development of a physics-based dexterity and puzzle game.
I started the week by making a working spike obstacle, which was made in about the same way you think it would be. At the moment, whenever the ball touches the spike, it simply destroys the instance of the ball. Obviously there'll be more that happens in the future, but for now that's really all I need it to do.
This also came along with an update and reorganization of my physics collision layers, which now help to keep everything clean and separated!
The next one is a bit more interesting, as it's a working fan that will blow the ball upwards, which I think is pretty cool! I slightly adjusted the code found in this tutorial for my purposes, and it worked like a charm! I had some troubles at first when trying to make the system on my own, so I figured it'd be a smarter use of my time to consult some resources, and it certainly was!
After developing this obstacle, I figured it'd be a good time to start working on some early level designs. I decided that the spinning obstacle idea I had when making my trello board might not be the best for this game, as it would just serve to complicate the game further. I may experiment with it later on though, we'll see!
Here are those new levels, with the added feature of the "bump!" As I was messing around and playing the levels, I realized that being able to move the entire box kind of invalidates most of the obstacles I plan on making, so I started brainstorming some ideas and landed on the bump mechanic you can see here! This has completely replaced the original movement, and I like it a LOT so I think it'll stay for a while.
In regards to the first three new levels, I wanted to keep them simple, short, and cumulative, that way the player can build upon the skill they learned in the last level more directly. This is all very subject to change, but it's a start and I'm pretty satisfied with it so far!
I wanted to make sure I got the level system working as quickly as possible, that way I didn't invest any more time into the prefab levels before making sure that they worked. The good news is that they did! The system is pretty simple, there's just a level manager game object that holds an array of all of the levels, and when the win point of a level is reached it just moves down the list, destroying the current level and instancing the new one!
The level reset on losing was a bit more troublesome for me, almost entirely due to my conceptual approach, rather than any technical issues. What I was trying to do was access the lose state of EVERY spike in the scene EVERY frame, which is pretty obviously a terrible way of going about this, but I got so caught up with fixing technical bugs and reading documentation that I never really stepped back to think, "Is this the best way to do this?" What ended up helping me in this situation was thinking back to the signal system in Godot (which would've been how I implemented it in that), and how I could use that concept in Unity. This led me to the infinitely simpler and more straightforward method of simply accessing the reset level method in the level manager script FROM the spike whenever it's hit. Not only did this just work immediately, but it's also WAY more performant, and WAAAYYY easier to read for other people.

This small chunk of code is all that I ended up needing, which would be even funnier if you saw the lines and lines that I wrote to try and get the other approach working. While this may seem like a pretty unfortunate hiccup in development, I'm actually feeling pretty encouraged by it! It served as a reminder to consider everything at a more basic level and make sure the fundamentals are solid before going into technicals, which is a reminder I need quite often.
And that is week 2 done! Another pretty successful week in my book! I definitely got more comfortable with gameplay programming and instancing over the course of this week, and was very happy to work on my level design skills too. The next week is probably going to center around the dialogue system, as well as conceptualizing the visual aesthetic of the game. Exciting stuff!



Comments