maysasa.blogg.se

Unity spine2d rotate bone
Unity spine2d rotate bone










unity spine2d rotate bone

Quaternion mappedRotation = Quaternion.LookRotation(boneDirection, parentTransform.up) Īs you can see in this image, with this method the hands look in the same direction, forward, but still not rotated correctly, they have an offset from the desired result. My last attempt was this: Vector3 boneDirection = (boneTransform.position - parentTransform.position).normalized The problem is, that I can't seem to find a good way to map theese rotations. Return Quaternion.Inverse(tPoseRotations) * rotation Quaternion CorrectRotation(HumanBodyBones bone, Quaternion rotation) when rotation = Quaternion.Identity the left hand should look forward. So the class would be used with an API like this: /// This should return the rotation, where the bone pointing forward rotated by rotation.

unity spine2d rotate bone

(I would assume that Unity does something similiar under the hood, that's how I got the idea.) I had the idea to create a class, that puts the character in T-Pose, then maps the bones rotation. The bones default rotation is not the same as you would expect if you have seen the rig in another application before. the left hand's Z axis does not looks towards the top of the hand, but backwards, while the right hand's Z axis looks forward. Calculate a rotation, that can be used, to correct the Transform of the bones, so they get rotated as expected when manually rotated.Ĭharacter's bone Transform is not imported to Unity correctily, ie.












Unity spine2d rotate bone