Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Giantbean · Dec 11, 2019 at 02:32 AM · vrjointsattach

Add a joint at collision point between two objects. (SteamVR held object interacting with a hinged object)

How can one attach a held object to a movable object in Steam VR? For example Lets say I pick up an item with the Steam VR throawable script, This item has a way to grab another object such as a hook or pincer. Once I am holding this object I would like to be able to collide with a large overhead (Normally out of reach) lever (With a linear or circular driver or a hing joint). The lever would swing around on one side while rotating it with the held object on the other side.

Any ideas on how this might be done?

Update: I am trying ↓ this ↓ with no luck.

 using UnityEngine;
 
 public class TaggedCollisionJoint : MonoBehaviour
 {
     public string linkLayerTag;
     public float forceToBreak = 50;
     public float torqueToBreak = 50;
 
     // Start is called before the first frame update and allows the script to be disabled in the inspector. 
     void Start()
     {
 
     }
 
     void OnCollisionEnter(Collision col)
     {
         // Set a tag to make the conection selective.
         if (col.gameObject.tag == linkLayerTag)
         {


  //This ↓ works to make a solid connection between the tool and lever but breaks the lever off its joint.
         //col.transform.parent = transform;

         //This is not making a joint at all?
         // create a joint -Tested with character, configurable, hinge and spring joints, but no joint is made.
             CharacterJoint joint = gameObject.AddComponent<CharacterJoint>();
             // sets joint position to point of contact
             joint.anchor = col.contacts[0].point;
             // conects the joint to the other object
             joint.connectedBody = col.contacts[0].otherCollider.transform.GetComponentInParent<Rigidbody>();
             //Set the forces which will break the joint.
             joint.breakForce = forceToBreak;
             joint.breakTorque = torqueToBreak;
             // Stops objects from continuing to collide and creating more joints
             joint.enableCollision = false;
         }
     }
 }

Comment
Add comment · Show 1
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 Giantbean · Dec 13, 2019 at 05:17 PM 0
Share

The S$$anonymous$$m VR documentation says:

Objects can be attached to and detached from the Hand. Only one
object can be the object in focus of
the hand but multiple objects can be
attached to the hand at the same
time.

So if only one object can have focus but multiple objects can be attached... How would I use a tool in the players hand to interact with an otherwise out of reach object? I have been looking over documentation and testing things for days but I'm stuck and need some assistance from the community please.

I try to search this and come up with things like https://www.amazon.com/Vive-Reacher-Grabber-$$anonymous$$obility-Rotating/dp/B00O47NWE6. alt text lol. Sure that's the tool I want to recreate virtually but in a Vive H$$anonymous$$D not a Vive Brand reacher grabber.

grappler.png (60.1 kB)

1 Reply

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

Answer by Giantbean · Dec 17, 2019 at 09:00 PM

This is working for me.

 using UnityEngine;
 
 public class TaggedCollisionJoint : MonoBehaviour
 {
     public string linkLayerTag;
     public float forceToBreak = 50;
     public float torqueToBreak = 50;
 
     // Start is called before the first frame update and allows the script to be disabled in the inspector. 
     void Start()
     {
 
     }
 
     void OnCollisionEnter(Collision col)
     {
         // Set a tag to make the conection selective.
         if (col.gameObject.GetComponent<Rigidbody>() != null && col.gameObject.tag == linkLayerTag)
         {
             // create a joint
             HingeJoint joint = gameObject.AddComponent<HingeJoint>();
 
             //Set the anchor point where the wand and blade collide
             ContactPoint contact = col.contacts[0];
             joint.anchor = transform.InverseTransformPoint(contact.point);
             joint.connectedBody = col.contacts[0].otherCollider.transform.GetComponent<Rigidbody>();
 
             //Set the forces which will break the joint.
             joint.breakForce = forceToBreak;
             joint.breakTorque = torqueToBreak;
 
             // Stops objects from continuing to collide and creating more joints
             joint.enableCollision = false;
            // ↑ This ↑ Sometimes still makes multiple joints which breaks things?
         }
     }
 }

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

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

Related Questions

Configurable Joint Spring and Dampen Values 0 Answers

Trying To Make Burger Builder 1 Answer

Help Setting Configurable Joint Target Rotation to a child transform's rotation 0 Answers

Need help with configurable joint (VR Pickupable like shopping bag) 0 Answers

ConfigurableJoint Target Position/Rotation Issues? 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