Skip to main content

Time Saving Tools


Time Saving Tools

One of the original task’s programmers were faced with was to take a repetitive thing like solving math equations and cut down the time people were spending doing them by hand. The fact that programming can reduce the amount of time people spend on tasks is very valuable when considering long term projects like making games. It is easy to get caught up in thinking that things are just the way they are when considering something repetitive and time consuming like iteration during development.  However, when discovering tasks that you or your fellow devs are spending a lot of time on over and over again, it can be valuable to consider that there may be a more efficient way of doing things. And the cool thing about being a programmer and technology in general, is that there is always a more efficient way to do things. Only sometimes the time to develop a solution might take longer than the project will allow. Therefore, it is important to weigh the cost of developer tools vs the time it will save early in production.

This is taking forever

Around halfway through the production of Batteries Included we created a hex based level system were levels would consist of various types of hexes. The level a puzzle for the player to solve and the hexes the pieces the player would interact with to solve it. With the designs coming in for new hexes and levels to test we were going to be doing a lot of iteration to see what felt good and what felt bad with the new design.

 



Each Hex required a “ghost hex” (visual representation for places where hexes could exist) to snap to so the levels aligned up correctly and so when players picked up hexes, they were not able to place them inside of other hexes.
What this meant for iteration initially, was that inside unity we had to drag out the hex that we wanted to place for the level design we were implementing and make sure that its transform matched the transform of the ghost hex it was being assigned to. This became very tedious very quickly. It was obvious that something needed to be done.

The start of a solution

The rule of setting up a level was simple, everything will work so long as the transform positions align perfectly. So, I created a simple script called Hex Chooser that had a reference to all of the hex prefabs and used an enum to allow designers and programmers to select which prefab to use. Depending on which hex was selected the HexChooser script would use OnGizmoDraw() to then update the name of that ghost hex to match the selected prefab making it easy for designers to view the layout of the level they were designing.

OnStart() the HexChooser script instantiates the hex prefab chosen and aligns it to meet the position requirement for the ghost hexes to recognize the assignment of the new hex.
Now a level that would have taken 15 min to create via dragging out prefaces and copy and pasting transform values was as simple as clicking the ghost hex you wanted and selecting the hex that should be there for the design.

The One step more

One of the problems with my the HexChooser script that required attention was that there was no way for designers to choose the rotation of the hex they were selecting. Luckily hexagons only have six sides so it was easy enough to just use another enum that would change the rotation of the instantiated prefab.

Another problem emerged however, it was not immediately apparent to designers which side the front of the prefabs would be facing simply by selecting an enum labeled “Side Two”. Since I was already utilizing the OnGizmoDraw() to update changes to prefabs and sides it didn’t take long to decide that it was probably time to use the method for what it was designed for, drawing gizmos. To keep things simple, I had each ghost hex draw a line from its center to the side that was selected indicating which side the front of the prefab would be facing. And with that last change the Hex Chooser was good enough to start saving countless hours of dev time.

Closing thoughts

If there is one thing you should take away from this post it would be, don’t put up with repetitive tasks if you don’t have to. Save yourself and your team some time and sanity by recognizing where you can create useful developer tools.

Alex Bowling, Programmer

Comments