IK control following the mouse cursor


I have an animation used on video best practices of Unity, and I wonder if I can make a control “IK” follow my cursor during the game (something like Transform.LookAt)

The animation in question does not have any script was all done in the animation window … I confess I’ve searched about it and not find what I needed and did not know where to start.

In short, it would make the arm of my character following the mouse cursor.

Watch the video of how it would be:

I managed to fix it easily by adding the following script in my control IK :

using UnityEngine;
using System.Collections;

public class ArmRotation : MonoBehaviour {

	// Update is called once per frame
	void Update () {
		var pos = new Vector3(Input.mousePosition.x,Input.mousePosition.y,0);
		pos = Camera.main.ScreenToWorldPoint(pos);
		transform.position = pos;