- Home /
How do you 'get' specific bones in a character skeleton via script.
Hello! How are you?
I would like to know more about targeting specific bones on a character model via script.
I have a character I am controlling with a dual-stick controller. The right stick walks the character around, while the left stick turns the upper body.
I know I can create a simple 'lookat' script and place it directly on the bone I want to turn (in this case, the first spine bone above the pelvis). However I would like to keep the character controls in a single script, currently located on the root node of the overall character, and simply call out to the correct bone from it.
I am a new programmer so apologies if this is more of a general programming question and not specific to Unity. I still greatly appreciate any help though! Thank you in advance!
Answer by Jessy · Jun 15, 2010 at 01:37 AM
Bones are just Transforms in Unity, so all you need to do is create a variable, then drag the correct Game Object onto the variable slot in the Inspector.
var bizzyBone : Transform;
You can then script anything you want with that Transform, and the Skinned Mesh Renderer's vertices that are weighted to that bone will go along for the ride (forward kinematics).
I always wondered when someone would make a Bone Thugs reference.. nice.
Answer by Tetrad · Jun 14, 2010 at 10:56 PM
Check out the head look controller
http://unity3d.com/support/resources/unity-extensions/head-look-controller
I did! It's in C#! Is there a Java Script equivalent? I don't feel like it's a good idea to switch languages when I'm just getting the hang of the first one... I've compared the two and I'm unable to parse the latter. :( Thank you though!