Skip to content

Instantly share code, notes, and snippets.

@coxlin
Created July 24, 2019 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coxlin/01bab4a0f20687534188422d881c8f5d to your computer and use it in GitHub Desktop.
Save coxlin/01bab4a0f20687534188422d881c8f5d to your computer and use it in GitHub Desktop.
using UnityEngine;
public sealed class IKControl : MonoBehaviour
{
[SerializeField]
private Animator _animator;
[SerializeField]
private bool _isIKActive = false;
[SerializeField]
private Transform _lookObj;
private void OnAnimatorIK(int layerIndex)
{
if (_animator != null)
{
if (_isIKActive)
{
if (_lookObj != null)
{
_animator.SetLookAtWeight(1);
_animator.SetLookAtPosition(_lookObj.position);
}
}
else
{
_animator.SetLookAtWeight(0);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment