Aim at target with animated character.

Hi.

I have a 3rd Person camera behind my player and it’s looking at one target (aimTarget), I want the player points its arm at that aimTarget by rotating bones. Player has a mecanim controller. Technically I want to make a shoot animation by code. Using Unity Free so I can’t use IK (I think). I’ve tried this already:

function LateUpdate(){
    var aimDir = aimTarget.position - shoulder.transform.position;
    shoulder.transform.localRotation = Quaternion.Lerp(shoulder.transform.rotation, Quaternion.LookRotation(aimDir), Time.deltaTime * 20.0);

}

Used LookAt an localEulerAngles but just get crazy arm movements.
Thanks.

Don’t rotate bones. You just need to play an aiming animation.

To get the rotation you can use a layer of the head, or simply rotate the whole character from its origin. (This will not look as good as a top body look at animation though)