58 lines
1.2 KiB
C#
58 lines
1.2 KiB
C#
using System;
|
|
using RootMotion.FinalIK;
|
|
using UnityEngine;
|
|
|
|
namespace NBF
|
|
{
|
|
public class PlayerIK : PlayerMonoBehaviour
|
|
{
|
|
public enum UpdateType
|
|
{
|
|
Update = 0,
|
|
FixedUpdate = 1,
|
|
LateUpdate = 2,
|
|
Default = 3
|
|
}
|
|
|
|
public UpdateType UpdateSelected;
|
|
|
|
private LookAtIK _LookAtIK;
|
|
|
|
[SerializeField] private float transitionWeightTimeScale = 1f;
|
|
|
|
protected override void OnAwake()
|
|
{
|
|
_LookAtIK = GetComponent<LookAtIK>();
|
|
}
|
|
|
|
|
|
private void Update()
|
|
{
|
|
if (UpdateSelected == UpdateType.Update)
|
|
{
|
|
IKUpdateHandler();
|
|
}
|
|
}
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
if (UpdateSelected == UpdateType.FixedUpdate)
|
|
{
|
|
IKUpdateHandler();
|
|
}
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if (UpdateSelected == UpdateType.LateUpdate)
|
|
{
|
|
IKUpdateHandler();
|
|
}
|
|
}
|
|
|
|
private void IKUpdateHandler()
|
|
{
|
|
_LookAtIK.UpdateSolverExternal();
|
|
}
|
|
}
|
|
} |