• 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 Indemonai_Games · Jul 06, 2019 at 02:26 PM · vrdoorhingejointfixedjoint

[VR] Door with Hinge Joint opens when hand moves in the wrong axis

Hi,

 
First of all, I should say that this is the first time I am doing something more complex than "just testing" with Hinge Joints, so it's possible I am missing some setting somewhere that automagically fixes the problem I am having here.

 
So, here is the problem I am having: I have a Hand object, controlled by a VR controller, which can interact with "Interactable" objects. I also have a door (I made a quick door prototype with basic geometry just to develop this functionality) which consists of a parent object, the door frame (scaled cube) and a door handle (cylinder). The handle is an "Interactable", and the parent object has a collision, Rigidbody, and Hinge Joint, which is set at the correct place, with the correct limits (I tested them out with the Motor function, and the door opens and closes within the limits, no problem). The problem arises when I interact with the door, and before I lay out any details, basically, instead of the door opening when I pull in my body's direction (door opens towards me), it opens when I move the hand towards the right. I'm confused. So here is how everything is laid out:


First, a video of the problem itself:
https://youtu.be/Rr-X1pjpi18

 
This is my Door GameObject: Door GameObject

 
This is my Door's (main parent GameObject) Components: Door Components 1 Door Components 2

 
My Frame Components: Frame Components

 
Handle Components: Handle Components

 
And finally, Hand components: Hand Components


How it works:

 
Basically, when the hand touches the Handle's trigger collision and the user presses the Trigger button on the controller, it will attach the door's Rigidbody to the hand's Fixed Joint, like so:

 

void Grab(IGrabbable grabbable)
{
    if (!CanGrab || grabbable == null || grabbable.GetRigidbody() == null) return;
    fixedJoint.connectedBody = grabbable.GetRigidbody();
}

So, the Handle (grabbable here) sends back the door's Rigidbody through GetRigidbody(). This is what I also use to grab objects and move them around, which works flawlessly.

 
Technically that is it. Nothing else is being done with the hand or the door until we let go of the Trigger button on the controller, which just calls a function called "Ungrab()" that sets the fixedJoint's connectedBody to null.

 
This is driving me a bit crazy, I managed to get it to work by turning doors into a special type of IGrabbable, that basically checks the position of the hand in FixedUpdate() and updates the door's rotation accordingly, but I feel like it's extra code that is not needed because I feel like the FixedJoint and HingeJoints should technically work. Why it's opening when I move to the right and not pull it away from its original position is beyond me.

 
I hope this was clear enough. If someone has any more questions I need to clear up please let me know. If you know what's going on here and a way to fix it, please, by all means, give me a hand over here (no pun intended, or maybe it was). Thank you for reading through this!

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by MikD · Oct 21, 2020 at 01:49 AM

I think this may be a case of the physics system doing its best to mirror your exact hand gesture while still following the limits you've set in the hinge joint. When you are attaching the hand to the door handle via the fixed joint, the handle is attempting to pull the door into position by matching not only the position of your hand but the rotation as well. A tried and true method is the one posted by a user named Valem on Youtube. He created a "fake" door handle (I refer to it as a "handle force") that is an invisible interactable that you can grab and move around independently of the door itself and then have the actual handle of the door, attached by a FixedJoint to your main door, use the physics engine to "follow" that "force". He used the MoveToPosition? command I believe. If you're making doors in Unity, the easiest method is to use the new XR system that can treat some interactables as velocity based check items. This means (from what I can see) that the object itself won't move but you can check how fast the item would have been pulled if you "could" grab it. You can use it to check for handles being pulled, wheels being turned, switches being flipped, whatever.

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 fotod1 · Dec 21, 2020 at 10:09 AM

Hi @Indemonai_Games , I am dealing with the exact same problem .Did you figure it out by any chance?

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

141 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 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 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 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 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 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

My Fixed Joint springs back to Zero. 0 Answers

Doors and Hinge Joints 1 Answer

make a lever with physic ? hinge or spring joint ? 0 Answers

How do you create a door? 1 Answer

Connectors with unintended effect of spring before breaking up 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