Published on

Getting a Bone Transform from a Humanoid Animator in Unity Scripting

  • Evelyn
    Full-time IndieDev.
    I'm Japanese, so please forgive me if my English is strange.

Please share this article if you like!

Thank you for visiting Evelyn GameDev Blog.

I'd like to get the Transform of the bones of a humanoid 3D model.

It's not uncommon for people to think, "I don't know what to do.

Isn't that what you think sometimes?

When you want to display an effect at a specific bone position of a character, it is useful to be able to easily transform the bone from a C Sharp script.

Table of Contents


First, make sure that the Rig's AnimationType for the model you are using is set to Humanoid.

By the way, this article uses a UnityAsset for a 3D model called Naoko. If you like it, go ahead and buy it!

There are fixed types of humanoid rigs, such as Spine and Hip, etc.... And each has a corresponding bone Transform assigned to it.

Overview of the code

To get the joint of Transform from the Animator, use the method GetBoneTransform.

Unity Doc of Animator.GetBoneTransform

You can get all the bones at once with the following code.

If you want to get the transform of the head bone, you can do so by writing the following.

//Get Animator
Animator animator = GetComponent<Animator>();

//Get the Transform of the head (head), check in the log)
Transform head = animator.GetBoneTransform(HumanBodyBones.Head);
Debug.Log($"Hip : {} : {head.position}");
The following is the code to get all bones at once, so please copy and paste it into your project.


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
using System;

public class GetBonesOfHumanoid : MonoBehaviour
    private Animator _anim;

    void Awake()
        _anim = GetComponent<Animator>();

    private void Start()
        foreach (HumanBodyBones boneId in Enum.GetValues(typeof(HumanBodyBones)).Cast<HumanBodyBones>())
            Debug.Log($"boneId: {boneId}, int: {(int)boneId}");
            if ((int)boneId >= (int)HumanBodyBones.LastBone)
            Transform bone = _anim.GetBoneTransform(boneId);
            if (bone)
                // TODO: Implement as you see fit for your project.

After running this code, We can get the Transform information for each Bone in the console as shown below.

Wrap up

In this article, we got the bones of Humanoid from the script.

Summary of this article

Using the GetBoneTransform method

I hope the contents of this article are useful to you.

If you like this blog, please subscribe to my Youtube and follow me on Twitter!

Please share this article if you like!