Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

enter image description here

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.

share|improve this question
2  
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. –  Philipp May 16 '13 at 13:05
add comment

2 Answers

up vote 11 down vote accepted

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.

share|improve this answer
4  
+1 It's hard to be random and deterministic, fake it. –  Byte56 May 16 '13 at 5:17
3  
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. –  msell May 16 '13 at 5:26
    
well, i did not understand what you meant by bouncing path –  Vishnu May 16 '13 at 6:08
2  
@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. –  Nicolas Raoul May 16 '13 at 7:07
1  
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. –  Vishnu May 16 '13 at 8:09
show 3 more comments

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.

share|improve this answer
    
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'. –  Vishnu May 17 '13 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. –  Philipp May 17 '13 at 8:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.