Search Unity

Moving hand bone with rotation of connected bones

Discussion in 'Scripting' started by chiblue3D, Apr 16, 2013.

  1. chiblue3D

    chiblue3D

    Joined:
    Apr 25, 2012
    Posts:
    19
    My challenge is that I have a humanoid mesh with multiple animations, I am not using mecanim. I want to control the location of a empty object which is a child of the hand and move it to a specific location defined by a transform. After studying the head look script I see that I need to construct a chain array for each bone from the shoulder to the hand, this I have done. My problem is that I know the location the hand is at and the location I want to move to, but I am somewhat at a loss as to how I calculate the rotation of the connected bones to get the hand to the location I want it move to.

    I know that I could create an additional animation, but my problem with this is that the target location is not static, the goal is to simulate my character picking up objects that are at different locations in the scene. Can anyone give me a pointer on how I would calculate the relative rotation of each bone to get the hand to the place I want it to be. I tried to adapt the head look script but can only get the hand moving lateral not vertically. i.e. around the body, but not up and down.