Mirrored rotations

I am making a character which mirrors a player in VR

I am trying to rotate the character’s hands to mirror the player, so:

  • Player forward is character forward
  • Player right is enemy left
  • Player up is enemy up

You can freely move around the character, so I cannot simply only flip the Z and Y (euler) rotations
I already have the positioning (maybe a bit hacky, so if you have tips for this let me know) of the hands working, it’s just the rotation giving me a headache

Does someone know how I can properly calculate this?

You can be a bit blunt with mirroring rotations. If I recall correctly you simply add a minus to one (or two) quaternion components, and it’ll flip in a mirror. There are no side-effects to this and it won’t break in the future. It’s basically a shortcut to a much more involved mathematics, and when you deconstruct and reconstruct the matrices, a couple of quaternion signs is all it boils down to.

My advice would be to print out the actual quaternion values, and check out the differences between the mirrored (desired) and the straight (input) version, because I can’t tell you exactly which components will do what you want (you basically want to find a proper axis-aligned plane; in your case that’s probably ZY).

edit:
If you end up with a consistent quaternion but one that’s rotated 180 around some axis, that’s also not a problem, you just make an Euler around that axis, and cancel it back by multiplying. You can prebake this Euler quaternion (if you print it out it’s an orthogonal, like (0,1,0,0)).

Would this work since I can move around the character and the character looks at me in all time?
Then different axis do different things, right?

All rotations will behave consistently if you consistently apply the mirror transformation to them. Since matrix computation comes last, and very much depends on input transform, consistent assignments will always lead to consistent results in this regard.

In other words, if you input rotation A, then modify it to -A and never skip to do it, all that Unity will ever know is -A. If I understood your question correctly.