Spin the Wheel, solve new puzzles written by the show’s producers, and win prizes. Challenge your friends and family through Facebook or play with millions of other players from around the world! Make it a daily habit and challenge yourself to new exciting puzzles and fun categories every day! NO PURCHASE NECESSARY. Void where prohibited. Open to permanent legal residents of the 50 United States and the District of Columbia and Canada (excluding Quebec), 18 years of age or the age of majority in the entrant’s state/province as of 8/24/20.

Wheel Of Fortune Daily Prize Winner

Jump To:
  1. Scene Setup
  2. Scripting

Objective

In this blog post, I’ll show you how you can implement a spin wheel/wheel of fortune in your game.

Step 1 Introduction to Wheel of Fortune

I guess, you already know what Wheel of Fortune is.

If you’re fond of playing Candy Crush, you should have already spun that Daily Booster Wheel countless times.

Spin & Win from 8 Ball Pool is also quite popular among gamers.

Or,

You might have seen it on some reality TV game shows, where a person spins a wheel to get a prize or a task to win the prize.

Wheel Of Fortune Daily Spin

Wheel Of Fortune Daily Puzzle Answer

Do you want similar kind of wheel in you game?

If yes! Then you have come to the right place!

It’s quite simple, but you might find a couple of things tiny bit tricky and confusing.

Worry not! I will try to make it simple as I can.

Let’s get rolling then..!

Step 2 Scene Setup

Let's Setup the Scene.

2.1 Wheel Setup

  • Set your wheel in the scene view. Make sure the partitions on the wheel are of same size.
  • Set small circle colliders on the edges (you need to create another empty GameObjects to store colliders) and set them as children of your wheel GameObject.
  • Now to keep the hierarchy neat & tidy you can create another empty GameObject as parent to the collider objects.

2.2 Arrow Setup

  • I’m taking a simple black cube to represent an arrow; you can use any of your favorites.
  • Add a BoxCollider2D & a HingeJoint2D component to your Arrow object.

If you’ve never encountered HingeJoint component before, it works as a hinge joint like we use in doors & windows.

Spend some time to play with its properties to get your desired result.

You can also refer to the Unity Docs for more detailed descriptions:

We’ve completed the scene setup now.

It should look something like this:

Step 3 Scripting

This time there’s only one script for us to worry about. (That’s a good thing, right?)

Note

Before I start explaining the code, attach the script to your wheel GameObject so that you can see the effect of code. That will make things easier to understand.

3.1 Animation Curves

As you can see in the code I’m using Animation Curves to set the wheel in motion. You can set a variety of shapes in these curves to have various kinds of motions for your wheel.

Animation Curves look like something below:

To access the curves, click on the curve in the inspector tab.

Also DO NOT forget to set the proper size of prize list.

Now to Update() method:

  • It contains 2 random numbers and a coroutine call: SpeenTheWheel()
  • itemNumber sets the item which will be under the arrow when the wheel stops.
  • maxAngle (or finalAngle)denotes what the final angle will be.

[Yes! We’ll know the result before spinning the wheel. But don’t worry; it’s still a mystery for our players.]

Let's check SpinTheWheel() coroutine:

  • At first the timer, startAngle and maxAngle are initialized.
  • After that a random animation curve is selected.

And the while loop inside:

  • The code inside is to calculate angle (rotation in z) for the wheel.
  • Here Evaluate() of animation curve gives the value of curve for given time.

The spinning logic for our wheel ends here.

Step 4 Conclusion

Now it’s up to you how to use the prize on the itemNumber that we get at the end (which we knew from the beginning :) ).

Now you know why we never got that so called 'BIG PRICE' or 'JACKPOT' EVER..!!

Now hit play and spin the wheel to see what you can win (Don’t cheat :P).

Wheel Of Fortune Spin Game

Simple isn’t it? If you still have any doubts leave a comment & I’ll be back (Just like Arnold Schwarzenegger would say!).

Also check out our other awesome Unity Tutorials right here.

Got an Idea of Game Development? What are you still waiting for? Contact us now and see the Idea live soon. Our company has been named as one of the best Unity 3D Game Development Company in India.

Created on : 07 July 2016

An Addictive Gamer turned into a Professional Game Developer. I work with Unity Engine. Part of TheAppGuruz Team. Ready to take on Challenging Games & increase my knowledge about Game Development.

PREVIOUS POST
Beginner’s Guide: Learn to Make Simple Virtual Joystick in Unity

Wheel Of Fortune Daily Puzzle

NEXT POST
The Mystery of WaitUntil & WaitWhile in Unity 5.3 Revealed!!