Question by
musicalhq · Jul 30, 2018 at 07:33 AM ·
animationfirst person controllerinverse kinematic
How to use Inverse Kinematics to make a character look where the mouse is pointing (mouse look)?
I want to make a 3D character be the "body" of a first person controller. I want the head/arms to follow the camera. I think the best way to do this is with Inverse Kinematics but I don't really understand what they are - the documentation is not very clear.
Below is the script I currently have on my 3D rigged character:
using UnityEngine;
using System;
using System.Collections;
[RequireComponent(typeof(Animator))]
public class IKMouseLook: MonoBehaviour
{
protected Animator m_Anim;
public Transform lookObj = null;
public float m_LookWeight;
public float m_BodyWeight;
public float m_HeadWeight;
public float m_EyesWeight;
public float m_ClampWeight;
void Start()
{
m_Anim = GetComponent<Animator>();
}
void OnAnimatorIK()
{
m_Anim.SetLookAtWeight(m_LookWeight, m_BodyWeight, m_HeadWeight, m_EyesWeight, m_ClampWeight);
m_Anim.SetLookAtPosition(lookObj.transform.position);
}
}
What is wrong with this/am I on the right lines, or is this completely wrong?
Also, is Inverse Kinematics a pro-only feature?
Comment
Your answer
Follow this Question
Related Questions
Why does this work? 0 Answers
Blender IK in Unity 5 0 Answers
Fix my animation with Final Ik 0 Answers
Confused About Animation... 1 Answer
Unity IK Pass creates Animation lags. 0 Answers