Touch devices and drawing go (excuse the pun) hand in hand. And what better opportunity to draw than being a barista?
The biggest challenge was getting the line drawing to look and feel great. Turning a world position into a UV position proved to be the simplest part, with Mesh Colliders providing a built in function. My first several attempts were all about drawing straight into the texture, but none of them recreated the sensation of drawing with a pen - the lines were more a collection of dots. This led to the current implementation, which uses an offscreen line renderer and render texture. Having a line renderer means that the collection of points will always connect, even if there's not many points to work from. The render texture is then overlaid onto the cup's texture using a simple renderer.
Now that you can draw onto the cup, I needed a mechanic hook for why you're doing all of this drawing. This led to "calling out" the order by having to type in the name using a keyboard. The idea was to have players discern their own handwriting, forcing them to balance speed with accuracy. There's also a fallback keyboard where you can call out the ingredients, just in case the name can't be uncovered.
Other than that, this prototype required frequent input management: drawing, rotating, dragging, you name it. Unity's build in input is great for getting things up and running quickly, but is less adept at handing input between layers and objects. For the additional control, I implemented a dummy input catcher using Unity's Event System, and then forwarded it to a custom ray caster. For one, this switched the input to sphere casts (fingers are giant), and allowed for much greater input filtering. The custom keyboard also required some input finagling, with touches being handed back and forth between the buttons and the keyboard backing. I've reimplemented a similar system on so many projects it might be time to generalize it!
All in all, this was a great exercise! I got to do a little bit of polish, a little bit of temporary art work, a lot of input work, and got back into render textures. As well, quickly bringing all of the different components and methods together was an interesting challenge. After playing through the build, the prototype isn't terribly fun to play. It all feels good, but having to move between the counters is cognitively too intense. At the moment, the clearest solution is to make the game multiplayer, with one player taking orders and the other calling them out.
If you're looking for more details, I kept a blog of the project here.