Search Issue Tracker

Active

Votes

19

Found in

5.4.3p4

Issue ID

891981

Regression

No

The joint.angle value changes when the parent changes rotation

Physics

-

To reproduce:
1) Open attached project and scene in it
2) Play it
3) Select "TwoProblems"
4) In scene view, start rotating it by y axis

Expected: In console, joint.angle value stays the same as it is only parent changing rotation, not the child
Actual: Angle changes upon rotating

Reproduced: 5.4.3p4, 5.5.2p4, 5.6.0f2, 2017.1.0a5

Comments (2)

  1. 38589f0868f300c37c053c509733dd74?d=mm

    jeroenopdebeek

    Nov 18, 2019 21:39

    For a simulation I'm running I have connected an arm to the robot base with a hinge joint. When the robot base rotates around a different axis than the hinge axis, the hinge.angle messes up, and becomes unusable.

  2. A65266f9aae96c1e83ee9fd945664cf4?d=mm

    Hamburgert

    Nov 18, 2017 08:58

    Reproduced the angle issue in 2017.2.0f3, and found a relatively simple way to reproduce it in the editor:
    1: Create two cubes, cube A and cube B, and give them rigidbodies.
    2: The Rigidbody on cube A should be kinematic, such that cube B can hang below cube A.
    3: Attach a HingeJoint to cube B and connect it to the Rigidbody on cube A.
    4: Attach a simple script to debug the value of hinge.angle. See example script below.
    5: Enable limits from -90 to 90 degrees.
    6: Enable motor, force 5, targetVelocity 50. (cube B should hit the limit at some point)
    7: Play the scenario
    8: When cube B hits the limit, use the editor (while still playing the scenario) to switch targetVelocity to -50
    9: The hinge.angle will now reset to zero. (Note: The limits still seem to respect the original hinge.angle)

    Example debug hinge.angle C#

    using UnityEngine;
    public class ReportAngle : MonoBehaviour {
    private HingeJoint hinge;
    void OnGUI () {
    if(!hinge) hinge = gameObject.GetComponent(typeof(HingeJoint)) as HingeJoint;
    GUI.Label(new Rect(10,10,100,20), "angle: "+hinge.angle);
    }
    }

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.