Unity Slot Machine

  1. Slot Machines For Home Entertainment
  2. Unity Slot Machine
  3. Unity Slot Machine Template
  4. Unity Slot Machine

Unity infinite loop of moving sprites (Slot Machine reel). If anyone have experience in making slot machines, please share it with me. Thanks and have a nice day. Rise of egypt slot machine it is the player’s responsibility to ensure — before signing up at the casino and agreeing to these terms and conditions — that they are not violating any rules in the jurisdiction in which they live, and with gambling sites still open and growing. Just knowing that Frank, basic unity 3d in slot machines to get.

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.

Do you want similar kind of wheel in you game?

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

Slot

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.
Unity Slot Machine

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

Slot Machines For Home Entertainment

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

Unity Slot Machine

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.
Unity slot machine github

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..!!

Unity slot machine tutorial

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

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
NEXT POST
The Mystery of WaitUntil & WaitWhile in Unity 5.3 Revealed!!

Slot Machine Demo

Classes

Unity Slot Machine Template

  • Reel (Assets/SlotGame/Scripts/Reel.cs)
    It have sprite renderers as childs and update renderers based on internal cursor values(List).
    When ‘ReelStatus’ is set to moving, ‘moveValue’ is increased and cursor values is updated automatically.
    Then renderers is updated using ‘OnRenderUpdated’ event callback function.

  • Machine (Assets/SlotGame/Scripts/Machine.cs)
    It provides a common interface for slot machines and have reels as childs.

CREATE BY

Unity Slot Machine

  • Sanghun Lee
  • Email: tkdgns1284@gmail.com
  • Github: https://github.com/bss1284