I'm aware that in Unity, when you want to add (e.g.) a weapon to a character, you parent it to the "hand" bone of the character etc...
Well I'm trying to add a hat to a character in unity when it's clicked (and the head of the character is moving around beforehand), and I want the hat to always be in the same position on the characters head, no matter what position the (animated) head happens to be in when it's clicked.
I tried making a reference mesh in blender (just a cube), and then setting the hat mesh to the same position of that mesh in unity, and to do that I tried parenting it to the head bone and then positioning it on the exact spot of the head in the blender model, but I did this by using the "Child Of" restraints and apparently blender restraints don't render to unity.
SO I'm not sure if making a reference item in blender was the perfect solution, but how can I set the position of the hat to the same position on the characters head?
EDIT:
I'm using a basic CharacterController for the character, and basically my character starts as a capsule object with the CharacterController and then I hide the capsule mesh and make my .fbx model a child of the capsule, and when moving I only rotate the model, not the capsule (if that's relevant), but I (also) want to be able to place objects on NPCs that are moving around, and so far the way I'm making those is just adding a capsule collider to the .fbx and adding click events to it with event triggers... anyways here's the the node structure of the NPC model if that helps:
the "teffilinBox" is the placeholder that I manually added after it imported to Unity, and it's what I was trying to get automatically by parenting with Blender, which didn't work.
BTW, I found another way to make meshes children of bones in blender, by going into pose mode and manually parenting the mesh to the bone, which WORKS in blener and it APPEARS to work in unity, although; the problem:
In blender, when you parent to a bone, it doesn't actually parent to the bone itself, it just weights it 100%, and it's actually a child of the armature only, with 100% weighting, so when I import it to unity, it doesn't recognize the parent-child relationship at all, but it still moves with the head so I guess it recognizes the weighting...
When I tried to make the hat object a child of the placeholder, it wasn't affected by the head at all, since in unity the placeholder itself isn't an actual child of the head, it just looks that way. And when I tried to parent the hat to the head, then just adjust the world position to that of the cube, it was always way off.
SO I just found a workaround that works, in case anyone else is having this problem: in Blender, when making the placeholder, just move to the first frame of the animation and position it but DON'T parent it to anything, then give it some unique name like "placeholder_Head" and then in Unity, on one of the start functions, find that gameobject (or ALL of the game objects that start with "placeholder" and then extract the other part of the name with Regex or something) and THEN parent it to the correct bone, in unity script, and afterwards, you can attach the hat object as a child of THAT, since now the placeholder is a real child of the bone. That worked for me, if anyone knows of how else to do it, I would like to know :) 'cause the main problem with this method is I'm not sure how to programmatically add all of the placeholders as children to the respective bone, because you can't just get a gameobject name with regex (Finding Game Object with Regular Expressions), without literally looping through all of the gameobjects or something like that... So does anyone know another way to do this (pretty basic) thing?
PS: to try to duplicate my issue to see what I mean, just get a rigged character in blender and try to make a placeholder cube or something then select the armature, go to pose mode and select the cube and shift-select the specific bone you want to parent it to, then make the animation and see how it moves with the bone in blender, but then import it to unity and try setting another object to the child of the placeholder with script any localPosition at 0, you'll see it doesn't work at all.