Randomly spin a wheel

In the game engine I am trying to make a reel spin randomly, such as in a slot machine. What I want to do is to have the spin initiate when a key is pressed, and then spin a random number of spins and/or degrees and then stop. I am somewhat familiar with the game engine, so I can get an object to move, rotate, etc. when a key is pressed. I can also get it to rotate a random number of times, by a fixed number of degrees each time, but it really lasts for only a moment when the key is pressed. I’d like it to spin a few times after the key is released and then come to a stop, just like when you pull the handle on a slot machine. I am not at all familiar with Python, so a script isn’t something I could use. Any help is appreciated.

What about using a timer property and a random actuator?
If a key is pressed it will randomly generate a number in the timer property, e. g. 5 seconds.
And if the timer is between 0s and 10s it will rotate with a motion actuator.
The higher the generated number is the shorter ot will spin.
I hope that was what you wanted to know!

How exactly does the timer property work and how would you use it?

The timer property will start to count when the game starts.
You can handle it just like any other property, in this case you would use a random actuator for the timer property, that assigns it to a random time and a property sensor that sends positive signals as long as the timer is between 0s and 10s.
Just try it out its very simple :wink:

Thanks, I tried what you said, but I don’t think I understand exactly how to set up the game logic blocks. I haven’t used property before. I am new to the Blender Game Engine. Maybe you could explain a little more detail?

You could apply a random torque to the wheel and let it spin till it stops due to damping.
It would require a very simple python script. If you want me to make one, then ask.

Bill2rag i will Upload a blend, i think this is easyer for you to understand than my explenation!

Thank you.

Here it is as simple as it could be :wink:

Attachments

random spin.blend (662 KB)

Fluppi393 -
Thank you! I have made my version now and it works. I don’t understand it all yet but I have a better idea. I will study the setup and try different settings, and that way I will learn more. I appreciate your help!