I'm trying to do the following:

  1. Have a rotation only (no transforms) with x,y,z.

  2. Each rotation axis above respectfully having a minimal and maximum rotation angle with a current angle.

  3. This will be for each bone of said character's skeleton, note the weights will be applied as per usual when doing animations, however there will be no animation data.

bones to rotation info, apply changes, info back to bones, apply changes, info back to bones...

Q: SetBones And GetBones, how would I get and set the bone data?


public class BoneControllerClass : MonoBehaviour {
    //used to modify the bone data struct for each bone (ediable via Unity Editor)
    public BoneConstraintData[] BoneData;

    //gets refs to bone data from character
    public Bones[] GetBones(){ /*..Help..Here..*/ }
    public BoneConstraintData[] SetBoneConstraints(BoneConstraintData[] _BoneData) { /*..CODE..HERE..*/}
    public void SetBones(BoneConstraintData[] _BoneData){ /*..Help..Here..*/ }

    public void Start(){
        // generate bone data with zeros
        BoneData = GetBones();
        // set bone data constraints
        BoneData = SetBoneConstraints(BoneData);

    public void Update(){
        // do something for smooth clamping, optionally this could be applied above as with Delta Time...
        // CODE EXAMPLE HERE, optionally another function can be added...
        BoneData[0].currentXAngle = 12.0f * Time.DeltaTime; //or BoneDataNew[0].currentXAngle = 12.0f; 

        // applies new bone rotation information, (note each bone carries the bone information of rotation like in IK Bone Logic...)

//holds Min, Max, Current Angles And Bone Ref.
public class BoneConstraintData{
    string bone_name;
    float minXAngle, maxXAngle, currentXAngle;
    float minYAngle, maxYAngle, currentYAngle;
    float minZAngle, maxZAngle, currentZAngle;

I'm using version 5.x.x of Unity 3D.

  • \$\begingroup\$ Where is the question? \$\endgroup\$
    – kolenda
    Jan 5, 2018 at 13:32
  • \$\begingroup\$ @kolenda how do i acquire the bone data and then set it with an updated version? \$\endgroup\$ Jan 5, 2018 at 13:52

1 Answer 1


I'm not sure what exact setup do you have on your character but the last time I've worked with bones in Unity they were just a transforms in GameObject hierarchy.

I've had some GameObject representing a character and one of their children was "ROOT" or "HIPS" and it had children for the rest of the bones.

I couldn't find an example for entire character but here you have some pictures with bone hierarchy:


Look at your character and find a name of main bone GO, at the Start or Awake you can find this object by name and then you can iterate over its children to get/set bone transforms.

One other idea to consider:

If you change the string in your BoneConstraintData to GameObject you could store bone reference in your class instead of a name. Then you could iterate over bones only once, on read and when you compute your final data you can do something like this:

for( Data data in dataArray )
    data.bone.setSomething( data.something );

This should be faster than iterating over bones again.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .