I want to share with you my experience with hand rotation. I had a lot of problems before and I think that maybe some other noob, like me, will enjoy with my solution:
My first problem were the rotation. As we already know Euler rotation aren’t so good because of gimbal lock and minimal angular changes that causes maximum rotations, so I had to tweak my rotations and adding something here, subtracting there, invert axis and so on and so forth.
While looking at your solution had different angular recalibration due to different hand’s bone axis rotation. Thus, since quaternion does not suffer of gimbal lock and are best for rotation here comes my solution at the problem:
Why not rotating the Hydra controller quaternion to match hand’s quaternion? Doing so I can avoid tweak for recalibrating hands and just use the rotation of the hydra and the hands will rotate perfectly.
- First of all we need to calibrate, so after putting our self in T-Pose we press the left Hydra button and then do the calibration
some times the HydraID is inverted, so we check and swap it if needed. We get the shoulder mid point and into Set Quaternion Offset we get the difference (in quaternion) between Hydra and hand quaternion, and save the value locally (code will be added below). - In playerController we get, every tick, the Hydra controller data and save position and rotation in local variable that will be given to the animation blueprint of the character.
We add the position of the hydra with the position of our hydra-shoulder mid-point and the shoulder midpoint of the character (is a fixed position). GetProperHandRotation rotate the Hydra quaternion with the offset quaternion saved during the calibration and in output it give the “real” rotation of the hands relative to the T-Pose. - is the code
I had to create temporal variable, it is probably a waste of resources but without doing so it crashes all the time
PS. I had to modify the plugin to get the quaternion in blueprint. Probably the good way will be to attach the plugin to the playerController.cpp but I found much easier and readable accessing via blueprint.
Sorry for my bad english, I’m working on it.