Created
July 24, 2019 19:26
-
-
Save coxlin/01bab4a0f20687534188422d881c8f5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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