Search Unity

[2D] Prevent joint anchor be pushed away from connected anchor ?

Discussion in 'Physics' started by rryba, May 26, 2018.

  1. rryba

    rryba

    Joined:
    Feb 21, 2017
    Posts:
    8
    Hello, i cant find any solution to my problem.
    I have a 2 rigidbodies 2d, main and child, connected with hinge joint attached to child. Issue is when adding force to parent and child collides with other object, child been pushed away from connected point. I want connect child object permanently to this place, allow only rotate thus physics interation with other object.

    I've tried connect they with distance joint and set only max distance property but this doesnt helps.
    Is there any posibility to make connection like this with some joint ?
    upload_2018-5-26_14-38-48.png upload_2018-5-26_14-43-17.png
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,481
    All the joints are "soft" joints and won't give you perfectly rigid connections/constraints. That said, the solver does its best. Have you tried increasing the number of iterations in the physics settings? The defaults are not always appropriate.

    In some cases however, and it's not clear whether this is one of those cases or not, it's not possible for the solver to come up with a "correct" solutions depending on the collision scenario it's faced with.
     
    Tset_Tsyung likes this.
  3. rryba

    rryba

    Joined:
    Feb 21, 2017
    Posts:
    8
    Is there any possibility to simulate hard 'joint' which interacts on collisions proper way as its joined to other object ? I think that shold be an easy step but i ran out of idea's instead of writing all new mechanic .
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,481
    I don't follow your set-up tbh. Why do you need a RB on a parent and a child? Why not have a single RB with a collider and colliders on a child attached to the same RB?
     
  5. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    401
    This seems like it's behaving as though it's a bug. I've followed this video precisely and my hingejoint2d just falls into oblivion when something hits it, but only while attached to another body: https://unity3d.com/learn/tutorials/topics/2d-game-creation/hinge-joint-2d

    Also, no springiness on hingejoint2d?

    EDIT: The "Connected Rigidbody" must be set to Kinematic or Static for the child hinge joint 2d to not fall into space. Still though, where's the spring setting?
     
    Last edited: May 31, 2018
  6. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,481
    Please don't hijack existing threads. Could you please create a new thread for your subject.

    Thanks.
     
  7. rryba

    rryba

    Joined:
    Feb 21, 2017
    Posts:
    8
    You can image this as a element of existing object , which have some push resistance, for example, hmmm, gun trigger ? When i start apply some velocity with angular velocity to parent (in our example for a gun), an element (gun trirrer) without additional force, shouldn't move or be pushed by any forces, and always rotate around connected point. How can i achive somelike this ?
     
    Last edited: May 31, 2018
  8. blairroa9999

    blairroa9999

    Joined:
    Apr 17, 2021
    Posts:
    1
    If anchor is pushed away. Then you should try changing collision detection in rigidbody2D from continous to discrete. Do these changes in that gameobject where hinge joint component is added. It works properly.