• Unity
  • Control Bone Euler Angles in Unity

  • Изменено
Related Discussions
...

I can't find any methods that will let me control x y and z rotation of a bone. Is it possible?

I am using bone.Rotation, ShearX and ShearY and they work fine. I want to rotate a face bone around x and y so that the face gets distorted on impact with an enemy.

Seems like maybe it used to be supported, but this one doesn't compile for me now:

bone.eulerAngles = new Vector3 (0, 0, 90);
https://answers.unity.com/questions/985631/how-can-i-rotate-a-bone-from-script.html

I'm on the Spine 3.8 and Unity 2020.3.2f1

Use transform.

foriero написал

bone.eulerAngles = new Vector3 (0, 0, 90);

A Bone from spine-csharp is not a Unity Transform, so this is not valid code. bone.Rotation already is the single euler angle that you want to adjust. You just need to adjust it at the right time, using e.g. the UpdateLocal callback delegate as described here:
spine-unity Runtime Documentation: Life cycle
spine-unity Runtime Documentation: Getting and Setting Bone Transforms Manually

I think he means the bone transform, which has a rotation, translation, scale, and shear

I think I get it. I'm using the wrong metaphor. I should move bone up and down, not to rotate it around x.

ohthepain написал

I think he means the bone transform, which has a rotation, translation, scale, and shear

While I don't understand what you mean by "the bone transform", I'm fine if you do 🙂.

ohthepain написал

I think I get it. I'm using the wrong metaphor. I should move bone up and down, not to rotate it around x.

It does not matter which of the local Bone properties x, y, rotation, scaleX, scaleY, shearX, shearY you change, you should always change them via the UpdateLocal callback delegate as linked above. This way you update your local bone locations after animations have been applied, but before world locations of each bone are calculated. If you update them at the wrong time (e.g. in Unity's Update or LateUpdate), they will potentially be overwritten by animations or have no effect.