ultrafop

Hi all!

I think it is a really quick and easy question. Maybe so much so that a search for the keywords is bringing up way more complicated stuff.

I'm just wondering how to grab the tranform.rotation information of a Spine point in Unity at runtime so I can spawn projectiles (e.g. grenades) and set their rotation to the rotation of the point. I am using "pointAttachment.GetWorldPosition(slot, skeletonAnimation.transform)" to set position at spawn just fine, but I'm having trouble finding a way to do this for rotation.

Thanks for any help!
ultrafop
  • Posts: 13

Harald

Please check out the PointFollower component which is intended for letting a transform follow a point attachment of your skeleton:
spine-unity Runtime Documentation: PointFollower
If you wan't to avoid using a separate component, just copy the necessary code parts over to your code.
User avatar
Harald

Harri
  • Posts: 4164

ultrafop

Hi Harold,

Thank you for your reply!

I was actually looking the PointFollower script over prior to my inquiry. I felt like there had to be a more straightforward way to get the Quaternion from the point (or, if it's easier, a bone) which is what led me to post here. The PointFollower script feels like it would be made for some sort of attachment that hang around a character (like a sword, perhaps), rather than a projectile which would have many instances flying away from a character in space. My perspective is that, if I add the PointFollower script to a projectile prefab, or even pieces of it to a projectile prefab, that's a substantial amount of redundant code that would be better housed in the object instantiating those projectiles. I've looked at the Unity documentation and at the PointFollower script but still I'm wondering how one might merely grab transform.rotation for a bone or a point? Is there any way to do this without using parts of the PointFollower script or is this really the only way to go about obtaining a rotation?
ultrafop
  • Posts: 13

Harald

You can also use bone.GetQuaternion() which is provided in SkeletonExtensions.cs.

You could alternatively directly access bone.WorldRotationX and bone.WorldRotationY as described on the API reference page:
Bone worldRotationX
Bone worldRotationY
User avatar
Harald

Harri
  • Posts: 4164

ultrafop

Hello again!

This was super helpful! Exactly what I needed. Thank you for your help!
ultrafop
  • Posts: 13

Harald

Glad to hear it helped! Thanks for getting back to us.
User avatar
Harald

Harri
  • Posts: 4164


Return to Unity