Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug Configurable joints - angular limit configuration not being respected on dots conversion

Discussion in 'Physics for ECS' started by RDeLucaRS, Mar 23, 2023.

  1. RDeLucaRS

    RDeLucaRS

    Joined:
    Mar 21, 2023
    Posts:
    5
    on conversion of a configurable joint any angular motions set to limited is not respected at all, and acts as if it has full range of motion for the axis. locked angular motions do work, so it seems to be only this one setting.

    In the video below the objects in green are GameObjects and the objects in yellow are converted entities. The left objects use a Configurable joint with locked YZ axis and a limited X axis. The objects on the right are using a Character joint with limited movement. The GameObject versions are following their set constraints and coming to rest whilst the entities versions completely disregard their set limits. the character joint when converted to an entity also exhibits extreme twisting behavior's that the GameObject version does not



    the issue is also present in the joints conversion scene within this physics sample project https://github.com/Unity-Technologies/EntityComponentSystemSamples/tree/master/PhysicsSamples

    is this an issue that has been made aware of, and is their a fix in the works? Or a potentially temp fix we can apply on our end? We ideally don't want to use other joints are we are converting an existing physics game object setup, and want to maintain the originals feel exactly, or as close as possible, when converting to DOTS.
     
    Occuros likes this.
  2. daniel-holz

    daniel-holz

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    81
    Could you please provide a reproduction case for this behavior?
    I just tested the angular limit in the configurable joint, and unless you set the stiffness and damping to 0 in the corresponding angular limit settings, the behavior is as expected.

    See here for a video of the behavior I witnessed. This is with the latest pre-release.

    And here is a video showing the same Configurable Joint with PhysX at the top (in the scene) and Unity Physics at the bottom (in the subscene) simulated simultaneously. The behavior is identical, apart from a slight timing offset in Unity Physics due to the asynchronous subscene streaming when entering playmode, which is expected.

    Finally, a video of the same situation here but with the Character Joint. Also here PhysX at the top and Unity Physics at the bottom. The behavior is identical.
     
    Last edited: Mar 25, 2023
  3. RDeLucaRS

    RDeLucaRS

    Joined:
    Mar 21, 2023
    Posts:
    5
    Hey @daniel-holz

    Cheers for the information. And you are correct, both our spring stiffness and damping was set to 0 in our game objects in our test code before conversion. As well as in our original project that we are working to convert to DOTS.

    Am I right in thinking that the game object solution always enforces restrictions that are set in terms of the angular limits, and the DOTS physics is more of a soft restriction that requires these spring values to be set? And if so is it the case that as long as we set these spring stiffness and damping values that we will get an exact conversion? Or is it a case that we will need to fiddle about with the values and feel out the final DOTS conversion?
     
  4. daniel-holz

    daniel-holz

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    81
    I will check but what I'm suspecting is that the PhysX joint version has a fallback to some default stiffness when stiffness is zero. In Unity Physics we model zero stiffness as zero stiffness, which means no resistance. So the behaviour you are seeing, where limits don't have any effect is physically speaking correct, considering the parameters provided.
    For better compatibility we could though mimic that default behavior.
    That would create a matching conversion for this special case and fix your use case from what I understand.
    Would that be an agreeable approach?

    And you can btw rest assured that the stiffness and damping values are intended to be accurately and reliably converted and modelled in Unity Physics. You shouldn't have to fiddle with them to find the matching setting.
     
  5. RDeLucaRS

    RDeLucaRS

    Joined:
    Mar 21, 2023
    Posts:
    5
    Mimicking the conversion in the case we set would clear up confusion, that way there is always a 1 to 1 conversion in the case of joints that have been set up in the same manner as our projects. As initial we thought the conversion was not factoring in the limits. But now knowing how it works does explain it and clears up that misunderstanding. So having a note in the docs for this one edge case would also be enough.

    Though I feel pretty confident that we can convert our existing project reliably with the info you have provided :) we have already got results that are looking really good on conversion when adjusting the stiffness values
     
    daniel-holz likes this.
  6. daniel-holz

    daniel-holz

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    81
    That's great news. Thanks for the update.

    I also did further investigation and can now confirm that zero stiffness leads to a special case behavior in the PhysX simulation. See video here, which shows a Character Joint simulation of PhysX at the top and Unity Physics at the bottom. The joint has initially a default stiffness of zero. In Unity Physics this leads to zero resistance force applied by the limit as is physically correct, while the PhysX simulation causes the limit to be respected with a rather stiff limit behavior.

    Changing the stiffness in the PhysX-based Character Joint to a very low value (here: 0.0001) leads to the limit now also not being respected anymore which is expected with such a low limit stiffness.
    This shows that there is a specifically implemented singularity in the Character Joint behavior at zero for PhysX.

    Note that the special behavior is only implemented for exactly zero stiffness AND damping btw. As soon as one of these values is not zero anymore, the limit takes the provided parameters into account in a physically correct manner.
    See this screenshot here with a non-zero damper value but a zero stiffness value as example:
    non zero damping with zero stiffness - PhysX.png
    The top simulation (PhysX) leads now to the expected viscous (only damping force) limit behavior.
     
    Last edited: Mar 29, 2023