Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
Iseldiera's avatar
Iseldiera
Protege
11 months ago

Interaction SDK 71 - Joint Rotation Active State - why is Pronation activated on both directions?

Hello fellow devs,

I am trying to detect a punch movement where there is a rotation of the wrist along the duration of the gesture. At the base of the gesture the fist is perpendicular to the floor and at the end it is parallel to the floor. To detect this, I am using the joint rotation active state component. Attached I am also sending the guide picture which is describing me what flexion, extension, radial deviation, ulnar deviation, pronation and supination choices represent.

 

In my case, on the right hand, rotation would be anticlockwise and thus pronation is the correct choice. 

 


So I set up the component like this and with all the other velocity / transform / shape components, the rotation of the hand in the way I intend is working. HOWEVER, to test for false positives, I am also doing a rotation in clockwise way (which would be supination) and it is still getting detected. 

In other words, a positive pronation value such as 90 degrees is detecting both 90 degrees turn and -90 degrees turn in testing. Is this a bug, if not, what is a workaround / heuristic for me to only detect the 90 degree anti clockwise turn? 

Thank you in advance,

2 Replies

  • Today I did another test with the Joint Rotation Active State and tested radial deviation. It is the same issue. It is activating on the rotation in either direction, which, I believe, should not be the case. I should be able to distinguish if a player is rotating it to the left than the right. I thought giving plus and minus degree values would do that, but no, no matter what amount you put, it detects it in both directions. 

    Is there any way to detect directional or clockwise / anticlockwise rotation using this component?

  • Chatgpt just solved it for me so I wanted to give the answer for those who might get stuck at the same place in future.

    So, I gave the script to chatgpt and asked it what is going on. Here is what it said:

    Currently, it detects rotation in either direction around the chosen axis. Internally, the code does:

    worldDeltaRotation.ToAngleAxis(out float angle, out Vector3 axis);
    float axisDifference = Mathf.Abs(Vector3.Dot(axis, worldTargetAxis));
    float rotationOnTargetAxis = angle * axisDifference;

    Notice the use of Mathf.Abs(...) on the dot product. That means the script only checks how much rotation occurs around the axis, without distinguishing clockwise vs. counterclockwise (or pronation vs. supination, etc.). If you need only one direction to trigger “Active,” you would have to modify that logic so that it does not take the absolute value and instead checks the sign of the dot product or uses a cross product to determine direction. As written, the script considers the magnitude of rotation along that axis in both directions.

    I then asked it to add a directional one for each of the vectors (flexion and extension are good for both hands, for radial deviation, ulnar deviation, pronation and supination I told it to do it hand specific, since it will be a different directional rotation for each. i.e. radial deviation which is rotation towards thumb will be opposite direction for each hand) and it gave me a customized script and viola, now I am able to detect rotation in either direction.