9th Grade Math to the Rescue
/With summer here and my day job being a teacher I have a lot more time on my hands all of a sudden.
Nobody has told me to show up for work, so I haven’t gone for a while.
I’ve also intentionally taken a little break from cranking out YouTube videos. Lets be honest the $8 a month I’m pulling in on ads isn’t paying the bills or a reason to flirt with burnout.
This is letting me spend more time working on my personal project. Right now the game is functional, or rather it fluctuates between functional and broken as I write more code, but that’s a not the story I want to share.
At the moment, I’m in the middle of iteration 2 of 37 in terms of polishing and refining the game mechanics. I’ve been squashing bugs left and right while making bits smoother and easier to use.
As part of those iterations, I’ve been working on the UI. Trying to make it less ugly, which is very different from trying to make it look good, and adding “juice” where I can. The ugliest of all the UI at the moment and roughest in terms of functionality is the “combat selection” panel. I want the player to be able to click on a “tournament” and have that tournament be centered in a scrollRect (Unity). So, I did a little playing on my own and it “worked.”
I sure am liking quotes today…
But reaching for a slightly higher standard than just “working”, I decided to use the google and see if other folks had a slick way to make it work. I found posts and discussions, but it all seemed overly complicated. Why is this hard?
Okay yes, Unity’s UGUI system can be pretty opaque at times… but again that’s not the point. Stop distracting me.
And then! Just like each morning during the school year… I remembered that I teach math. And this is just a math problem! I also teach physics. So I figured I’d gather some data and model the situation
9th grade math to the rescue!
The complex problem quickly showed itself to be just a linear equation, the position is based on the number of children (tournaments) in the scrollrect, which is fixed, and the index of the child I wanted to center. This is of course based on the children all being the same size (width in my case).
For those following along, yes, I have three variables so no it’s not “linear” but lets not get too picky. Nobody likes to sit next to that guy at the party so don’t be that guy.
And yes, it’s very ugly, but it works. That’s good enough to call it a win!
This was a good reminder, that as helpful as the interwebs can be sometimes the solution you find is a hammer and your problem isn’t a nail. A couple deep breaths, a few trips pacing around the living room like a crazy person and you can often find a simple(r) solution to your problem. I’ve found that showering and pooping also work, but I didn’t need the big guns this time around.