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
1
Question by Leroterr · Mar 30, 2015 at 09:33 AM · rotationspeed2d-physics

Spin a wheel realistically like spinning a Wheel of Fortune.

Is there a guide/tutorial/code somewhere where I can learn how to make my 2D wheel spin realistically when I touch and drag it? (On the Z Rotation Axis)

Like, the speed of its spinning will depend on how fast I touch n' dragged the wheel itself.

If I flick/rotate it very fast, the wheel would go spinning faster.

If I only moved it slowly, then it would barely spin at all. Just like what would happen if you spin a wheel like in Wheel of Fortune in real life.

Thanks!

Comment
Add comment · Show 4
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 flashframe · Mar 30, 2015 at 04:24 PM 1
Share

Check out this post

http://answers.unity3d.com/questions/34317/rotate-object-with-mouse-cursor-that-slows-down-on.html#answer-34318

You can modify this to suit your needs. Basically you store the speed that you were dragging, and use a Lerp to slow down the rotation to zero after you let go.

avatar image Leroterr · Apr 01, 2015 at 08:46 AM 0
Share

@flashframe How can I make it so that it only moves my wheel on the Z Axis? Since my 2D Wheel spins on the Z Axis only.

The code on that answer there works, but it rotates my object on all XYZ Axis. Thanks.

avatar image flashframe · Apr 01, 2015 at 01:32 PM 0
Share

You could remove

 transform.Rotate( Camera.main.transform.up * speed.x * rotationSpeed, Space.World );
 transform.Rotate( Camera.main.transform.right * speed.y * rotationSpeed, Space.World );

and add:

 transform.Rotate( Camera.main.transform.forward * speed.x * rotationSpeed, Space.World );

That would use horizontal movement to spin on the z-axis only. Alternatively, check out @Bored$$anonymous$$ormon 's answer below. $$anonymous$$ight suit your needs better.

avatar image Leroterr · Apr 02, 2015 at 08:50 AM 0
Share

I'm not quite sure what to do with what Bored$$anonymous$$ormon said. How do I add torque and what should I do after that? How can I make it move?

This is all very confusing for me even after I watch some tutorials.

3 Replies

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

Answer by florianveltman · Apr 01, 2015 at 02:07 PM

I would use a HingeJoint2D. Add the component to your wheel and set its anchor to the center of it. You can then use any rigidbody dragging script you like to move it at the speed you want.

Take a look at this video tutorial for a clearer idea on how hinge joints work. If you do not have any rigidbody dragging code yet, maybe take a look at the sample assets, filed under "2D" in the Import Assets menu.

Comment
Add comment · Show 1 · 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 mrosenschein · May 12, 2017 at 08:42 PM 0
Share

Hi, I know this is a bit old but I'm new to Unity and struggling with the exact same issue. Can anybody go into a bit more detail on how to implement the HingeJoint2D solution? Thanks!

avatar image
0

Answer by Safforn · Mar 30, 2015 at 09:50 AM

No tutorial, but you can measure the distance and time from a touch. If you know those two you can find out the speed. Then you can use Quaternion to spin the wheel with the speed you found out.

http://docs.unity3d.com/ScriptReference/Quaternion.html

Comment
Add comment · 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
0

Answer by Kiwasi · Apr 01, 2015 at 10:44 AM

Just constrain the centre of the object with a joint and then use add torque. Problem solved.

Comment
Add comment · 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

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

25 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

When applying AddRelativeForce object reaches higher speed when rotated 1 Answer

Different speed on different phones 0 Answers

Instant Rotation 2 Answers

Translating in world space only on y axis? 0 Answers

C# - How to vary rotation speed according to movement speed 1 Answer


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