Instancing a Scene and parenting to a Bone in my Skeleton3D at a specific position

Godot Version

Godot V.4.0.1

Question

Hello, I am building an avatar customization system! Currently I have my scene set up with my avatar (A 3D base model) that the player can pick and choose a hairstyle that is meant to be instanced into my scene.
Each hairstyle I have made is in a respective scene file, that gets instanced into the scene on a button press. The first attempt we had made us realize each hairstyle needs to sit on the head mesh at a very specific position, but we can’t figure out how to have :

  1. The Hairstyle instanced at the specific position and rotation

While also,

  1. The Hairstyle instanced to be parented at a specific bone in the armature. (The Neck Bone) In order to get the hairstyle to move with the mesh.

So far, we’re thinking the Hair is trying to instance itself at the very top of the bone, but even then, after trying to make it smaller but, it kept making the head mesh smaller…

So far we’ve had three different approaches :

  1. Position Based Script (This results in perfect positioning but not parented :

func yorkhair_inst(position, rotation):
var YorkHairScene = preload(“res://Meshes/Angels/Hair/york_hair.tscn”)
var YHinst = YorkHairScene.instantiate()
var NeckBone = $“…/…/…/…/Base_Angel/Armature/Skeleton3D/NeckBone”
#Position Coordinates for “York” Hair Instance
YHinst.position = Vector3(0.1, 9.9, -6)
#Rotation Coordinates for “York” Hair Instance
YHinst.rotation_degrees = Vector3(0, 63, 0)

func _on_york_hair_btn_pressed():
yorkhair_inst(position, rotation_degrees)
#Playing Animation
AP.play(“Posing001”)


  1. Adding as child of Neck Bone (This results in the instanced hairstyle being spawned at the top of the neck bone, like it’s floating above the head)

func yorkhair_inst(position, rotation):
var YorkHairScene = preload(“res://Meshes/Angels/Hair/york_hair.tscn”)
var YHinst = YorkHairScene.instantiate()
var NeckBone = $“…/…/…/…/Base_Angel/Armature/Skeleton3D/NeckBone”
NeckBone.add_child(YHinst)

func _on_york_hair_btn_pressed():
yorkhair_inst(position, rotation_degrees)
#Playing Animation
AP.play(“Posing001”)


  1. And Last…Combining both approaches (This results in the instance not coming into the scene at all and an error)

func yorkhair_inst(position, rotation):
var YorkHairScene = preload(“res://Meshes/Angels/Hair/york_hair.tscn”)
var YHinst = YorkHairScene.instantiate()
var NeckBone = $“…/…/…/…/Base_Angel/Armature/Skeleton3D/NeckBone”
NeckBone.add_child(YHinst)
YHinst.position = Vector3(0.1, 9.9, -6)
YHinst.rotation_degrees = Vector3(0, 63, 0)

func _on_york_hair_btn_pressed():
#Runs the York Hair Instance func
yorkhair_inst(position, rotation_degrees)
#Playing Animation
AP.play(“Posing001”)

Error :

Thank you for reading!

Add a Node3D between the bone and the instanced hair, this lets you offset the hair while the bone attachment can modify the Node3D parent.

In my project I have BoneAttachment3D > Node3D > MeshInstance the Node3D is altered by the bone so I am free to offset, rotate, and scale the mesh as I please.

1 Like

Works like a charm–Thank you so much!
I’ll have to put your name in the credits at the end :smiley:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.