Mana dragging, butler and more
Today, I will write the dev log a little bit differently. In the paragraphs below, I walk you through the steps I did today and hopefully, you will find it interesting and you could even use some of it in one of your own projects.
The Butler
The first topic of today is itch.io's butler. The butler is a small program that allows you to push and publish builds of your game automatically. I decided to try it out today, so I went to the link in the previous sentence and started reading.
After some setup, I had the butler installed and ready to use. The basic usage is that you run command
butler push directory user/game:channel
I did not want to always type in all the parameters and I thought that it could be pretty easy to set up a custom Unity tool that would run the command directly from Unity for me automatically. In order to recall how that could be done I brought up this video where Jason Storey creates a small tool that allows you to set up custom folder structure of an empty project with a click of a button. As I skimmed through the video I realized that this is simple enough that someone surely already did that and so instead of writing that tool myself (which would have been a great exercise, but let's keep that for some other day) I googled it and found this Unity package.
I glanced over the code and after realizing this is exactly what I wanted to build I added it to my Unity project and wanted to try it out.
Swapping mana
However, it would be a shame to publish a new build with no changes to the game so I picked some simple enough task from my TODO list: Swapping mana between heroes. To my surprise, this was super simple and I had it functional in less than half an hour. The implementation is a bit tricky, but it does the job marvelously:
If you drop mana into already occupied slot, it literally swaps the mana between the slot and the grabber before releasing it, so the "failed" release drops the swapped mana into the original position of the mana that was grabbed.
With this little change, it was time to test out the unity-butler package. It has a nice editor window with a couple of input fields to fill out and a button that says "Publish". With everything set up correctly, the Publish button will build your game with the current build settings, upload it to itch and publish the file. With WebGL builds (such as Dice: The Deliverance) it is necessary to tick the checkbox that says it will be played in browser the first time you publish using the butler, but then it's pretty seamless.
Nice! No more creating folders, building game, zipping the build, logging to itch, finding my game, editing it, uploading file and changing checkboxes. Now everything happens with a single press of a button.
Input system
After the success with butler I was motivated to continue with some small changes. Another item on my list was the ability to simply tap to grab mana dice and tap again to release instead of having to drag and drop. This functionality is especially useful on mobile where drag and drop is a bit inconvenient.
I spent about an hour with reading the documentation on various interactions and events that the input actions can fire and figuring out the right combination of interactions and actions to make it all work. Eventually, I had some ugly entangled implementation that did not really work. I scratched it all, brought up a piece of paper and wrote down what I actually wanted the behavior to be in all possible cases. I have read the documentation thoroughly and found out what it really means for each interaction to start, be performed, or be canceled.
After writing it all down I figured out that what I really want is a single interaction: SlowTap. On its started (button pressed) I want to remember if something was already held and if not, try grabbing something. Then on performed (button released after duration) if something is held, release it. Finally, on canceled (button released before duration) if something was held before started, release it.
This worked really well, except a skilled player would drag and drop really fast and then be annoyed by the fact that it just grabbed the mana and not release it. This could be solved by making the duration really short, but then it would be annoying for slow mobile players that pressed their finger on the screen for a bit too long.
The solution to this problem was to add another condition to the canceled case. If the player was not holding mana before started but then between started and canceled the mana moved some minimal distance, release it anyway.
With this addition, the drag and drop as well as click to grab and click to release work both very well. As a side effect, this rework of the Mana Grabber caused the script to shrink by about 30 lines of code and also simplified the controls as now there is a single GrabOrRelease action instead of two separate actions Grab and Release.
Thanks for reading and see you next time!
Get Dice: The Deliverance
Dice: The Deliverance
Status | In development |
Authors | Stopa, Moutes, Pozitreo, Shami42, Rozari |
Genre | Role Playing |
Tags | 2D, Dungeons & Dragons, Fantasy, micro-rpg, Short, Singleplayer, Tabletop, Turn-based |
More posts
- Quick hotfix - v1.2.1Aug 01, 2022
- Moster abilities and storyline - v1.2 updateJul 31, 2022
- v1.1 post-jam updatesJul 27, 2022
Leave a comment
Log in with itch.io to leave a comment.