x


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!

more ▼

asked Jun 14 '10 at 08:44 PM

artician gravatar image

artician
35 3 3 7

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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).

more ▼

answered Jun 15 '10 at 01:37 AM

Jessy gravatar image

Jessy
15.6k 72 95 196

Thank you very much!

Jun 15 '10 at 03:07 PM artician
(comments are locked)
10|3000 characters needed characters left
more ▼

answered Jun 14 '10 at 10:56 PM

Tetrad gravatar image

Tetrad
7.2k 27 37 89

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!

Jun 15 '10 at 12:38 AM artician
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1047
x215
x143
x34
x1

asked: Jun 14 '10 at 08:44 PM

Seen: 3237 times

Last Updated: Jun 14 '10 at 08:44 PM