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 SBull · Aug 14, 2014 at 06:29 PM · javascriptjitterconstraintshinge jointonmousedrag

How can I stop OnMouseDrag from overriding a hinge joint's attachment?

I am trying to create a springboard, where the player will click on an object sitting on the end of the board, pull it down with the mouse and release to launch the object into the air. I created a previous post trying to figure out how to do this with inverse kinematics, but then realized I might be able to achieve this effect with hinge joints. Currently, I have a series of hinge joints attached to several bones in a long board-shaped mesh.

However, there are still a few problems plaguing me. First off, I would like to have the tip of the springboard follow the movement of the object sitting on it. So in other words, if the player clicks on the object and drags it down, it appears as though the object is pushing on the springboard. I have tried making the last bone in the springboard's armature parent the object when it is clicked on, however this causes the hinge joint on the springboard to fight against the OnMouseDrag position as it constantly updates the position causing it to jitter constantly. I would like the motion to be nice and smooth as the player moves the mouse around.

Secondly, pulling the object away from the springboard causes the springboard to stretch. As soon as the object is released, the springboard snaps back into place, but this seems to be a result of the OnMouseDrag position overpowering the constraint of the hinge joint on the armature. Is there a way to tell the hinge joints to stay connected even if the mouse is moved away from the springboard's position?

Hopefully I explained all of this clearly enough. It's kind of a confusing issue unless you see it in action. Thanks in advance for any advice on how to go about this though.

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
0

Answer by smoggach · Aug 14, 2014 at 08:23 PM

Hey there. I have an idea of the kind of solution you're looking for. You need a buffer between your mouse drag position and applying force to the springboard. You're not going to get the results you want unless you manipulate your physical objects with physical forces only.

Myself I would have one script with a vector3 to represent where the mouse should be if it was moving smoothely. Then I would use OnMouseDrag to modify that vector3. Then in an Update function I would LERP this Vector3 towards the actual mouse position while applying a constant force to the spring based on the distance between that lerped vector3 and spring's resting position.

It sounds confusing but really the solution is just to have some kind of buffer translating mouse coordinates into the right forces to move your object where you want it.

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

22 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

Related Questions

Is it possible to only allow one direction of rotation using a hinge joint? 2 Answers

Setting Scroll View Width GUILayout 1 Answer

Very odd but harmless error? *Not that urgent* 1 Answer

destroy hinge joint component from another object in javascript 2 Answers

Disabling Rigidbody constraints on GameObject that script is attached to 3 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