- Home /
How can I set avatar's particular joint angle via script (mecanim)?
Hello,
I'm new to Unity and I'm working on project with mecanim avatar walk in combination with Kinect. Maybe I'm just missing something very obvious, but I'll be glad if someone can explain to me cause it's driving me crazy. I'm using scene from mecanim sample and trying to access joints in BotControlScript through Animator or getComponent.
The thing is, I need to access avatar's leg joints and set their angle manually in script, in order to set avatar's pose or even influence walk in progress.
I've searched forums and Unity documentation and found that I need something like Animator.SetIKPosition, but in that case Unity is doing movement to point for me and I need to edit particular joints separately.
Answer by tanoshimi · Dec 09, 2013 at 03:53 PM
If you want to override the joint rotation set by Mecanim you need to do so in LateUpdate(). E.g. to make the character's head always look towards camera, you could do something like:
void LateUpdate() {
Transform head = transform.Find("Armature/mixamorig_Hips/mixamorig_Spine/mixamorig_Spine1/mixamorig_Spine2/mixamorig_Neck/mixamorig_Head");
Vector3 targetPos = GameObject.Find("Main Camera").transform.position;
head.rotation = Quaternion.LookRotation(targetPos - head.position);
}
alright, I need baby steps :) I need to override $$anonymous$$ecanim by transform, and where can I find that "path" to joints, and what do I have to have attached to avatar (like animator, rigidbody), because that example is not working for me... is that Armature present for basic avatar?
Your answer
Follow this Question
Related Questions
Not all joints rotate in Mecanim while they do have animation on them. 0 Answers
kinect v2 - dressing room fitting problems, potential mecanim solution? 0 Answers
Useing root motion with native unity animation 0 Answers
How to animate a model that doesn't have arms or legs (just feet and hands) 1 Answer