Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by nerdjnerdbird · Sep 26, 2013 at 01:20 AM · bendbending

How do you create a realistic wheel of fortune style prize wheel?

How would you create a realistic wheel of fortune style prize wheel? I'm talking about a spinning cylinder with pegs on the outside and then a flexible stick that hits the pegs to slow it down (the wheel also has friction). The stick bending and then snapping back into place with each peg hit is important. Ideally it would have those suspenseful last peg hits occassionally where you aren't sure at which prize the wheel will stop. I'm not interested in the creation of the wheel so much as the physics behind everything in the scene.

Thanks!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by robertbu · Sep 26, 2013 at 02:18 AM

I ran a quick test and ended up with a wheel that worked well and had those suspenseful last peg hits. My recipe:

  • Created a flat cylinder for the base.

  • Replaced the default capsule collider with a mesh collider on the base.

  • Added a Rigidbody to the base.

  • Enabled 'Freeze Position' for x,y, and z;

  • Turned off gravity

  • Enabled 'Freeze Rotation' for x and z (y still allowed to move).

  • Added pegs as children. They had colliders, but no Rigidbodies.

  • Added flipper.

  • Added Rigidbody to flipper

  • Added hinge joint to flipper with anchor on the right edge of flipper

  • Set joint axis to 'Y'

  • Enabled 'Use Spring' and set Spring to 11 and damper to 1

  • Added the standard DragRigidbody script to an empty game object.

I'm sure by playing with the settings you can refine this setup even more.

alt text


wheel.jpg (39.6 kB)
Comment
Add comment · Show 7 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image nerdjnerdbird · Sep 26, 2013 at 06:11 AM 0
Share

First of all, thanks a ton! This is great.

I have a couple questions for you: 1) What is the point of the mesh collider on the base? The collider isn't actually hitting anything, just the pegs. 2) "Added the standard DragRigidbody script to an empty game object." What does this mean exactly and what is the point of this? 3) $$anonymous$$y biggest problem is speed. The wheel needs to spin quickly and the lots of pegs will be hitting the flipper one after another. Right now the flipper acts great but then if I increase the speed the physics calculations mess up because (I presume) the pegs are jumping into the middle (or straight across) the flipper. I tried using continuous dynamic collision detection, interpolation, and reducing the fixed timestep in the time manager of my project. $$anonymous$$y first 2 solutions didn't seem to do anything but reducing the fixed timestep does help... but doesn't get me to the point of a really fast spinning wheel hitting the flipper a lot. Thoughts?

Again, thanks a million!

avatar image Fattie · Sep 26, 2013 at 08:38 AM 0
Share

amazingly generous solution.

you say it doesn't work at high rotation speeds. expressed in "pegs per second" please tell us precisely when the problem kicks-in

conceptually if it "doesn't work" at high PPS, you will have to add another "mode" when the rotation speed is above that domain.

Robert, for the "high PPS" mode don't you agree it would be best just to have an animation of the flipper sort of "bent back, just out of the way, and shuddering/flickering" as if it is being flicked really quickly and erratically.

then in "high PPS" domain, just turn off the ordinat flipper and replace with the "actually just a flicky animation" flipper.

have a script on the wheel with a line of code that changes from one domain to the other based on the speed

avatar image robertbu · Sep 26, 2013 at 11:58 AM 0
Share

I wanted a collider on the base so that I could grab and spin it. By default a cylinder gets a capsule collider, so if you take a look in the Scene view, a squashed cylinder like this one would have a big sphere part of the collider above the top surface. This sphere would interset the flippers.

As for the speed issue, you've already done the things I would typically suggest. One other thing I did that may have an impact is to drastically reduce the mass of the flipper. I set it at 0.05. You might also set $$anonymous$$in "Penetration for Penalty" in the Physics settings to 0.0.

@Fattie solution to "fake" the high-speed movement should work fine if you get the ti$$anonymous$$g of the transition between "fake" and real movement correct. It's not something I would have though of. As usual his thinking out of the box comes up with a great idea.

avatar image nerdjnerdbird · Sep 26, 2013 at 04:09 PM 0
Share

Hey guys, you are awesome. Super helpful.

I think my problem was appearing because I was modifying the transform of the wheel in it's update function... 2 rookie mistakes in one. 1) Do not modify the transform of rigid bodies and 2) do not do it in update function. Fixedupdate is where I should add forces.

Anyways, right now I'm just adding an enormous torque at the beginning and I reduced the timestep and things are working awesome. The flipper $$anonymous$$IGHT skip a peg or two when it's spinning around really fast but honestly you can't tell because it's constantly being knocked in the right direction so it's not a big deal. I will definitely consider faking it in the end if I have to but right now it's looking pretty awesome.

Thanks again!

avatar image Belial · Jan 10, 2014 at 03:23 PM 0
Share

Hope I'll get an answer here ins$$anonymous$$d of starting a new thread. I used the method provided above and I'd like to understand/expand on a few things. I'm still a beginner in Unity so I didn't quite understand the solution for the "high PPS" problem.

And then my biggest problem: how do I check if the wheel (the flat cylinder) is no longer spinning? (so that I can read the score the flipper is on when it stops moving; this of course should happen only after the player has moved the wheel). I've made some empty objects with box colliders so that, when the wheel is no longer rotating, the one colliding with the flipper would give the correct score.

Thanks!

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Bend a 2D sprite using physics. 1 Answer

how can i make a joint like this in unity? 2 Answers

Bend 3d object (Mesh) at Runtime 2 Answers

2D Shader that bends vertices? 3 Answers

Bending a stick problem (Probably easy for an intermediate programmer) 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges