Tombola

Recreating a Tombola rotation effect in Unity. Tombola drums are roataing boxes usually used to shuffle prizes to be drawn at random.

Tombola
From Wikipedia

In the United Kingdom, a tombola is a form of raffle in which prizes are pre-assigned to winning tickets. ... Players pay for a ticket, which they then draw at random from a hat or tombola drum, and can instantly see whether or not they have won a prize.

I’ve been looking recently at games studios around the Sydney area. One company called SMG Studios has a site with a neat spinning tombola like menu. It feels so satisfying to click and has a lot of crazy results. What does SMG stand for? Soap Media Group? Who knows...  I hope it’s one of the many combinations that can be generated from the Tombola.

SMG Website

I thought I would try recreating the tumbling menu using Unity and animation events. Animation events let you call methods at a set point on the timeline.
Here is my Unity implementation and Code. It’s pretty close. I did miss the nudge on the logo when boxes are clicked. Unity’s lighting is a little darker and the menu scale is a little off but I'm happy with the result.

My Unity Implementation

The set up was pretty straight forward,

  • Unity primitives for the rectangles.
  • Use the Animation window to rotate the primitive over three seconds.
  • Adjust the animation curves to add some easing to the rotation.
  • Set up the Animator to have a trigger, that when enabled rotates the object.
  • Add an animation avent on the timeline to trigger the animator.

That's it! The text is generated at random from a list held in a scriptable object. When the rotation is triggered we generate some new text.

How the animation is hooked up with the event

I did run into an issue. If triggering an animation event at the end of an animation it fails to work.  I’m not sure why. To get it working  I needed to add the event a few frames before the end.