• 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 novello_io · Dec 09, 2013 at 04:36 PM · configurable jointbox2d

Configurable Joint 2D Equivalent?

I'm doing a game with similar mechanics to "Cut the Rope" - I actually have a system that works quite well - I use a Configurable Joint on each Rope Anchor, and connect it to a "Player Object", and set its linear limit to the length of the rope. I then use a Verlet method to generate a rope mesh which sags etc (but the physics are all controlled by the Config Joint).

However, it's a 2D game, using the 3D physics (rigidbodies etc) with axis restrictions- and 4.3 dropped, I'm trying to convert my system over, so I can use 2d collides etc, and make things more efficient.

I'm running into an issue with my rope system in that I'm not sure how to replace the configurable joint I use with a 2D equivalent.

My first thought was to use a Slider Joint 2D, to handle the variable length, but that didn't produce good results.

I then tried to use it in conjunction with a Hinge Joint 2D (with the hinge as the parent), which worked a bit better, and I could get a pendulum motion going, but would still have issues when the "Player Object" would fall from above, with the Hinge Joint at some angle - the Slider Joint wouldn't seem to contract, but instead the force would make the Hinge Joint rotate faster - which kind of makes physical sense if I think of a Slider which can only slide on one axis.

The Configurable Joint actually has its angular motion locked, and just moves along X and Y (I don't completely understand this...but it works).

Is there a 2D Joint or some combination that would allow movement along X and Y similar to a config joint, or some other method I could use to make this work?

Here is my code to initialize the Config Joint:

         //Adding a configurable joint to the rope anchor
         cj = anchorObject.AddComponent<ConfigurableJoint>();
 
         cj.anchor = Vector3.zero;
         cj.axis = Vector3.zero;
         cj.autoConfigureConnectedAnchor = false;
         cj.connectedAnchor = Vector3.zero;
         cj.secondaryAxis = Vector3.zero;
 
         cj.linearLimit = new SoftJointLimit() { limit = targetLength, bounciness = 0, damper = 0, spring = 0 };
 
         //We want to limit motion along the X and Y axis, to a maximum distance of "targetLength", and of course lock motion on the Z axis
         cj.xMotion = ConfigurableJointMotion.Limited;
         cj.yMotion = ConfigurableJointMotion.Limited;
         cj.zMotion = ConfigurableJointMotion.Locked;
 
         //The configurable joint doesn't need to rotate, but makes no difference if it's set to Locked or Free (don't really understand why at the moment)
         cj.angularXMotion = ConfigurableJointMotion.Locked;
         cj.angularYMotion = ConfigurableJointMotion.Locked;
         cj.angularZMotion = ConfigurableJointMotion.Locked;
 
         //Attach the configurable joint to the player's rigidbody
         cj.connectedBody = connectedObject.rigidbody;
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 novello_io · Dec 09, 2013 at 05:00 PM 0
Share

http://www.box2d.org/manual.html#_Toc258082974 - seems like a Box2D RopeJoint (8.13) would do the trick, but that didn't seem to get brought in?

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

What are the main differences between Unity Physics engine vs Box2d physics engine 0 Answers

Converting character to configurable joints 0 Answers

Box2D empty gameObjects not getting expected results code is included 0 Answers

Slide then lock slide when object is rotated past a certain angle. 0 Answers

If a joint has a Connected Body, does it ignore the Anchor position? 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