ReFocus Labs is a technology startup based in Pune, India, focusing on Augmented Reality, 3D game development, and adaptive user interfaces, leveraging BlackBerry 10 as their primary development platform; both ARKick and Pastry Push are BlackBerry 10 first.
ARKick is a contextual augmented reality app which is now Built for BlackBerry and even went on to win the BlackBerry AngelHack Challenge & the People’s Choice Award at BlackBerry Jam Asia 2013.
Following their most recent release of Pastry Push, I asked ReFocus Labs to share a little about their experiences, and Puneet Kohli and Shashwat Pradhan were kind enough to write about the road to a delicious, sugary release.
“I wasn’t very familiar with Unity at that point, but I took up the challenge and started the journey towards making Pastry Push a reality,” says Puneet.
The Initial Challenge
The first question that came to mind when developing our new game was, “How do we get this to work?” In HTML5 I knew I had to shift the coordinates of the main object and stop it at certain coordinates. But how do we translate this into Unity, where there are forces like gravity and more?
The first prototype of our simple box manipulating game was made by simply adding a force to an object until it collided with any other object bearing a certain tag. The idea seemed great, but had one drawback. Adding a force to our object meant it had real world physics applied to it and instead of moving exactly in a straight line, there was a slight variation by one to two degrees in the path. Because of this, our object used to get stuck at the edges of obstacles, and sometimes the collision was never detected until after the object moved into the obstacles.
Another issue was the size of the game board. We had a 10×15 board, which looked fine on the PC, but on mobile it was hardly visible and difficult to navigate around. We decided to go for a 6×10 board.
I scrapped the old method of collision detection and adopted a new tile-based approach, similar to the logic of chess: receive an input, check each tile in the given direction, and move to the final tile immediately. This method was much more efficient and helped us overcome our earlier challenges. As you can see, we had a basic GUI ready, and our levels were taking shape.
Our final version of the game uses much optimized code, taking advantage of ray casting. A tip for other developers: try to call as little as possible for every Update frame, as it can really decrease performance. Instead of ray casting in all 4 directions at once (which we were initially doing), we now ray cast in the direction of input after the input is given; this has increased performance by over 200 percent.
We Have The Core Laid Out, Now What?
About a month and a half into development, we had a basic slide-to-move game where players stop at obstacles and need to reach a certain point on the grid. We then began with our 3D graphics design to complement the theme.
We had some great graphic assets designed, but when importing them into Unity, they weren’t looking like we wanted. After some initial research, and some trial and error, we found out about the texture import settings of Unity.
For GUI textures, it’s best to turn off mipmap generation and keep the texture quality at compressed or 16-bit, in order to resemble the original truecolor images with minimum banding and without consuming too much space.
For in-game textures (such as our monster Moko and trapdoors), it was best to keep mipmap generation on and have our maximum size increased to 1024. This came at the cost of space but it was required in order create our spritesheets without any quality reductions.
Shaders were another confusing aspect. Using most shaders, we could implement shadows but we weren’t getting the feel we wanted. Finally we settled on the toon shader, which gave Pastry Push a colorful outset.
Unity GUI, A Challenge Every Developer Faces
Unity’s built-in GUI system is very expensive to use, as it has many draw calls per frame, but it gets the job done. On the other hand, there are GUI plugins such as NGUI that look and perform great. We used Unity’s native GUI system in some parts of our game, and GameObjects (quads) in other parts to simulate the feeling of a GUI layer. Some developers created their own GUI systems altogether; I’m really curious as to how and would love to learn from them.
Unity GUI is very simple to work with and offers a lot of flexibility, even though we had to sacrifice a little performance to use it.
The real challenge lies in handling multiple aspect ratios. For our native GUI-based components, we positioned and adjusted everything according to height, using a native aspect ratio of 9:16, which is the most common mobile resolution. For the quad-based GUI, we had to convert screen coordinates into game-world coordinates, calculating differences and readjusting accordingly. For the BlackBerry Q10, we adopted a different project file altogether, since the aspect ratio was different than our base of 9:16.
The Final Phase
Two and a half months into the development process, we had a fully functional game with working menus, audio, graphics and a great theme. This is what it looked like at BlackBerry Jam Asia.
We spent the next month optimizing what we had, making our gameplay more fun, adding animations, optimizing code and memory usage and adding gamepad functionality. All the while, we made sure the game looked equally good on the BlackBerry Q10 and BlackBerry Q5. Most of the time spent here was on testing different methods for achieving the desired result and seeing which one worked out best for us.
Overall, developing with Unity and BlackBerry 10 gives you a great feeling and a good workflow. The Unity Community is great and helps whenever you’re stuck with a problem, and the BlackBerry Developer Evangelist team is also really helpful. Overall, HTML5, Cascades, and Unity provides a brilliant development experience with BlackBerry 10.
Pastry Push has a lot more coming. There are still some features we are working on, and we hope to bring them out in a future update along with some insanely challenging levels! Do check out Pastry Push on BlackBerry World and give us your feedback, and also check out Pastry Push’s BBM Channel: C00147102.
If you have any tips of your own, or questions for the BlackBerry 10 Unity community, feel free to leave us a note in the comments or reach out directly to: firstname.lastname@example.org.