# make a sphere rolling on a roulette mesh stop at predetermined place

I have a roulette and a ball(sphere) placed on it. When the game begins the roulette spins. The spinning of the roulette and gravitational forces on the ball makes it roll along the 3d roulette mesh.

Now , in this roulette game of mine I have slots from 00 to 36. I want to make sure that after the roulette stops spinning the ball comes and stops rolling at my predetermined slot.

For example : if i set the target slot as 25 in the game, every time the roulette spins, the ball moves realistically along with it BUT comes slowly to a stop at slot no: 25.

I have tried 'slerp' the ball to its target position, but the realism is lost. The ball moves through the mesh. Which i don't want. I want the ball to roll like in real life.

• Just for the record: When players play with real money and their chances to win are actually lower than they appear to be, you might break the law in some countries. Commented May 16, 2013 at 13:05

Script one (or two or three) bouncing paths for the ball to follow. Adjust the rotation of your wheel model to cause the correct slot to land underneath the ball's final destination.

A bouncing path: construct complex animations made from many small movements of the ball over time, such that it appears to be natural physical motion around the structure of the wheel. Eventually, that animation will end with the ball settling into a slot and rotating at the same speed as the wheel. That location does not need to be changed, because the wheel can be rotated such that the correct slot is underneath the ball. One method for scripting these paths is to follow keyframes based on a spline.

• I was going to suggest the same, except having dozens (or even hundreds) of different starting values to randomly choose from. Otherwise the player will observe that the ball is always behaving the same way. Commented May 16, 2013 at 5:26
• well, i did not understand what you meant by bouncing path Commented May 16, 2013 at 6:08
• @Vishnu: Beforehand, calculate the angle by which the roulette turns. Then when showing the animation, initialize the starting angle so that the final position is the slot number you want. Commented May 16, 2013 at 7:07
• Yes, that is exactly what i'm trying now. I'm rotating the wheel by a n * 360 times before decelerating. and then I'll have to calculate the final position vector and then move the ball by 'slerp'ing and rolling. Commented May 16, 2013 at 8:09
• I would be very careful faking it with a gambling game (even as a mini game). If players figure out that the ball is following a set path (even if there are several of them) they may think you are cheating them and not play. I am also assuming you're not using real money. Commented May 16, 2013 at 15:48

Calculate the path in background, and then change the numbers when you render it.

Calculate a path based on random parameters, but do this invisible to the player. You now know on which field the ball will land. Then you render it visible, but before you do that you rotate the texture of the roulette wheel so that the field where the ball will land shows the number you want.

• But, the roulette numbers can be seen while spinning, they don't go so fast. Also the roulette spins to a top speed and then decelerates.So in any case the texture(like you said) cant be 'faked'. Commented May 17, 2013 at 3:39
• When the wheel is visible to the player between throws, you could cheat with camera perspective. You could do a dramatic zoom on the ball when it is thrown. During this zoom the wheel isn't visible. You can then calculate the physics in advance, modify the wheel, and replay the precalculated physics. Commented May 17, 2013 at 8:11