Slot Wheel Values?

Hello,

I am rotating a cylinder and using Random.Range to pick a number to rotate the cylinder to. The cylinder has 10 faces on it so my random number would be (RandomNumber * 36 +360) using 360 to make it go around at least once.

The faces on the cylinder have images of numbers on it 0 to 9.
If I spin the wheel (from 0) and a random number of 5 comes out then the cylinder would spin 180 which would land on the image 5 as expected (print(RandomNumber / 36):wink:

But here is my problem, if I spin the wheel again from this new position and the RandomNumber is 5 again then it would land on the image 0 instead of the 5. So Im confused as to how I would figure out the wheels image value from the RandomNumer?

Is there another way to figure this out?

Howdy! How about something like this:

if u get the last random number to var and do something like this:

spin = 10 - lastrandom + newrandom

Thanks for the response!

Im trying it right Now! :slight_smile:

Having shipped a few… um… quite a few… slot machines over the years, I can help out a little bit.

Slot machines have two types of wheel, fixed (found on both traditional slots and video slots) and dynamic (only found on video slots and only in certain jurisdictions or for non-gambling purposes). Sounds like you are trying to create a fixed reel slot machine. A reel has stop positions marked on it, so if you have ten symbols on your reel (a bit low as it is usually 30+ symbols with repeats), you have ten stop positions. You select a random number between 1 and 10 (or 0 and 9 if you are a programmer) and then rotate the reel to that stop position. If the reel rotated to zero degrees is stop position 0 and the reel rotated to 180 degrees is stop position 5 then you just simply decide what the stop position will be, put the value through a rotation function that gives you back an angle, and then perform a rotation on the reel to make it show that stop position.

You rotation function is something like:

int StopPositionsOnReel = 10;
SelectedStopPosition = Random.Range(0, StopPositionsOnReel);
float newRotation = 360.0f / StopPositionsOnReel * SelectedStopPosition

You can then use an interpolation to spin from the current rotation to the new new rotation, using something like iTween perhaps, to get a nice smooth ramp up and ramp down.

How to make 10 faces on cylinder??