# Question on Working Slot Machine.

Hello Everyone!

I am currently working on creating a working slot machine. At first only with 1 pay out line and 1 bet, then possibly add to 3 rows with max lines and 5 different bets. I understand how this would work in theory, as I am stuck in my blueprinting when I am looking to implement the payout of each side of my wheel.

My logic is;

``````Rotate said 12 sided wheel, then after its finished animation record the side based on the rotation from having it on 12 different 30* possible finishing points. However, I am unsure as of how to get that information and put it through its, i'll call it payout sequence, to the create the payout for the player.
``````

Would love to post my blueprints if this gets any attention! Much Love everyone!

Thanks,
Meci

I presume you are having trouble with keeping track of the value on each wheel, or how to store that?
You’ve probably got most of this done, but I’ll show you how I done it and how I keep track of states.
I have a blueprint with 3 movable static mesh actors, they are cylinders with 12 sides each (also 3 text render components, to test the state).
Below is an overview of the blueprints event graph:

(The set world rotation should actually be set relative rotation)

Here are the functions. First, MakeRandomRotation. It makes a random rotation, that is rounded to the nearest 30 degree angle, the 30 works for the 12 sided cylinder obviously but you could change it if you had less sides… You can also set min and max turns, mine are arbitrarily set at 16-24. This function is called to create a random rotation for each wheel.

The next bit after the MakeRandomRotation functions, the modulo of the full rotation, divided by 30 and truncated gives you the amount the wheel value has increased by. It’s ignoring complete rotations, and getting how many 30 degree rotations are left, so if there’s 2 30 degree rotations then the value of the wheel has increased to whatever it was at plus two numbers higher.

I added a function to set the play rate of the timeline based on how much the wheel is turning, so more turns, the timeline will take longer to complete, this is just visual. The *4 is just a multiplier so you can speed it up:

The timelines themselves are 1 second long, and have a float track and event track. The float goes from 0 to 1, curved like this so the wheel slows down before stopping, just a simple way of doing it. The event track calls an event at .25, this starts the next wheel.

The timeline sets the rotation of the wheel. Start rotation starts at 0 and is set in the next function. This should be understandable from the overview screenshot.

There’s a fucntion for each wheel to update their values - their state and start rotation, for when they are rotated again.
CurrentNumber, plus the amount it has increased, mod 12 so it loops back around. Doing it like this way actually makes side 12 equal to 0, but that shouldn’t matter.

I make a custom struct that contains 3 integers. This is used to store the result when all wheels are finished as below:

You could then make a function which checks if your result matches some value, like this:

So you can enter 1,1,1 or 7,7,7 or whichever into the function, and check if the result matches, you check for any you want to, and either branch, or set an enum based on the return value. You could then swithc on enum, for whatever happens for those results.

in use:

Obviously by doing it this way, the rotation value continues increasing if you never reset it, it wouldn’t really be neccesary to do it this way, it could be faked by spinning it and then just setting the rotation directly. Though you’ve probably got that part set up

Thank you so much! There were a couple parts of your blueprint that was unfamiliar with, but alongside your descriptions completely make sense as to the logic behind this asset.

Their were a lot of things i didnt consider, like rounding for example, simple concept but didnt know that was a possible node! Thanks for your help!

How did you make your setworldrotations not be a rotator input, but have one for each of the seperate float inputs?

Hey, if you right click the Pin click “split strict”, or break, I forgot the exact word right now

How did you create the custom struct?

Edit: I got this part figured out.

Sorry, I’m not exactly sure what you mean there, cna you explain better or post an image?

I figured that part out. What would be a more effecient way then running multiple “check results” functions to allow any 3 consecutive (1,1,1 , 2,2,2 , 3,3,3 ,) numbers to each produce a seperate outcome.

such as, 666 spawns 100 “coin” actors in winning tray below, where 777 spawns 200, and 111 spawns 20.

This macro would check that all numbers match, and also switches on what number it is, you should be able to use it for that