- Home /
Is it posible to adjust an animated bones POSITION at runtime. Not the rotation.
Hi, finding this bafflingly difficult.
I want to adjust the position of a single bone at runtime to create a stretching effect.
There seems to be no shortage of ways to aim a bone or set rotation but no way to offset it. eg: SetBoneLocalRotation() but no equivalent SetBoneLocalPosition()
Animator.SetBoneLocalRotation(HumanBodyBones, Quaternion) is doing a bit of behind-the-scenes work. HumanBodyBones is just an enumerator, so all it's doing is giving SetBoneLocalRotation() a point of reference for its own lookup process to find which Transform you want to apply the Quaternion rotation to. It also... checks whether the Animator is in the Inverse Kinematics pass and... complains if it's not, but doesn't do anything with the data? Whatever.
Anyway, if you've already set this up this much in the first place, Animator.GetBoneTransform(HumanBodyBones) will return the Transform data for the specified bone itself. Is it not feasible to modify the Transform, or even the animations?
Answer by CoughE · Sep 02, 2021 at 03:13 PM
Couldn't you just assign the transform in the armature? So if you have a hierarchy of
Armature
-Spine
--head
-Left arm
--Left Hand
-Right Arm
--Right hand
etc, and you want to stretch the right arm, just get a reference to the Right Arm transform and assign it's transform.position