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 cheliotK · Jun 25, 2013 at 12:25 PM · rigidbodyjoints

rigidbody affecting other rigidbodies: vibrating objects

Hello unity community,

I'm having an issue with how a non-kinematic rigidbody is affecting other rigidbodies (also non-kinematic). I have a pretty standard scenario: In a first person perspective, I have a model of a desk, with openable drawers, which have items placed inside them. The drawers have a configurable joint (set to mimic a spring joint) to limit their movement to one axis and give them a maximum travel distance, which anchors to the world. Furthermore, when a drawer is clicked, a joint is created between the drawer and an empty gameObject (which functions as a temp placeholder for the hand position).

Everything is fine up until this part, I can pull open the drawers, they stop where they are supposed to, and I can close them smoothly. However, if I place an item with a rigidbody inside the drawer (for example by dropping it in at the start of the scene), as soon as I click and create the joint between "hand" and drawer, the item starts vibrating, to the point that it shoots out of the drawer sometimes. Furthermore, if I open the drawer too quickly, the item disregards the drawer's colliders, and either shoots through the drawer walls, or falls through the bottom. Note that the item inside the drawer is not connnected to anything by joints, and is just resting on the drawer's bottom, by using gravity.

The following code snippet is attached to the drawer gameObject:

 if (Input.GetMouseButtonUp(0) && itemHeld == 1) {
          
          if (this.gameObject.name!="drawer")
         {
         heldObject.GetComponent(Rigidbody).constraints = RigidbodyConstraints.None;
         heldObject.GetComponent(Rigidbody).drag = 1.0;
         heldObject.GetComponent(Rigidbody).mass = 1.0;
         heldObject.transform.parent = null;
         }
         Destroy(hand.GetComponent(ConfigurableJoint));
         
         heldObject = null;
         itemHeld = 0;
         GameObject.FindWithTag("Player").GetComponent(objFocus).handsFull = false;
         activeItem = false;
         }
     
         else if (Input.GetMouseButton(0) && itemHeld == 0) {
             if(plrFoc){
         
                 Debug.Log(this);
                     
                 hand = GameObject.Find("itemHeldPos");
                 var handJoint;
                 if (this.gameObject.name=="drawer")
                 {
                 hand.AddComponent(ConfigurableJoint);
                 handJoint = hand.GetComponent(ConfigurableJoint);
                 handJoint.connectedBody = heldObject.GetComponent(Rigidbody);
                 handJoint.xMotion = ConfigurableJointMotion.Locked;
                 handJoint.yMotion = ConfigurableJointMotion.Locked;
                 handJoint.zMotion = ConfigurableJointMotion.Locked;
                     
                 handJoint.angularXMotion = ConfigurableJointMotion.Free;
                 handJoint.angularYMotion = ConfigurableJointMotion.Free;
                 handJoint.angularZMotion = ConfigurableJointMotion.Free;
                 handJoint.linearLimit.damper = 1;
                 }
         
                 itemHeld = 1;
                 GameObject.FindWithTag("Player").GetComponent(objFocus).handsFull = true;
                 activeItem = true;
             }
             else Debug.Log("too far");
         }

To clarify, the plrFoc is a boolean var in a script attached to the player, to check which object (if any) is in focus and is close enough to be picked up. The configurable joint being created in this script is the one between hand and drawer, and seems to be the one producing the vibrating item behaviour, as when I release the mouseButton (thus releasing the drawer) the item rests again.

Unfortunately, my unity knowledge is not that great, and although I have a feeling that it has something to do with physics and collisions, I have no idea where to look.

Thanks, and sorry for the long post..

PS. I've thought of some workarounds for this, mainly creating loose joints between items and drawer, and breaking them as soon as i touch the object, but I would prefer not to resort to this, as I may have to do this for lots and lots of small objects.

Comment
Add comment · Show 3
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 amphoterik · Jun 25, 2013 at 12:36 PM 0
Share

Does the item in the drawer need a rigidbody? could it just be an item nested to the drawer? Then it would move with the drawer without trouble.

avatar image cheliotK · Jun 25, 2013 at 01:07 PM 0
Share

Frankly, no, the item doesn't really need a rigidbody. However, we're still tinkering with the idea of being able to pick up objects in a half-life style(ie pick them up and hold them in front of the camera), and I think that requires a rigidbody component on the items. As I said, there are workarounds, I just want to see if there's a solution for this method as well.

avatar image amphoterik · Jun 25, 2013 at 01:10 PM 0
Share

That wouldn't required a rigidbody at all. Rigidbodies are only for when you need physics. Having a preset method of picking up an object by manipulating its position doesn't require physics. I would remove the rigidbody and put it back if you really need it. Cross rickety bridges only if you need to.

0 Replies

· Add your reply
  • Sort: 

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

17 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

Related Questions

Tying two players (Rigidbodies) together with a rope 1 Answer

Configure configurableJoint to act as the disctontinued driveJoint 0 Answers

Fixed Joint Rigidbody Colliding 1 Answer

Reset Joints to initial state 0 Answers

Hinge Joint On Little Noodle Carton (with pic) 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