修改arm
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using RootMotion.FinalIK;
|
||||
using System;
|
||||
using RootMotion.FinalIK;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
@@ -15,39 +16,41 @@ namespace NBF
|
||||
|
||||
public UpdateType UpdateSelected;
|
||||
|
||||
[SerializeField] private Transform _LeftHandTransform;
|
||||
// [SerializeField] private Transform _LeftHandTransform;
|
||||
|
||||
private LookAtIK _LookAtIK;
|
||||
|
||||
private AimIK _AimIK;
|
||||
// private AimIK _AimIK;
|
||||
|
||||
private FullBodyBipedIK _FullBodyIK;
|
||||
// private FullBodyBipedIK _FullBodyIK;
|
||||
|
||||
private ArmIK _ArmIK;
|
||||
// private ArmIK _ArmIK;
|
||||
|
||||
private bool _isLeftHandEnabled;
|
||||
// private bool _isLeftHandEnabled;
|
||||
|
||||
private bool _isRightHandEnabled;
|
||||
// private bool _isRightHandEnabled;
|
||||
|
||||
public bool isAimEnabled;
|
||||
// public bool isAimEnabled;
|
||||
|
||||
private bool _isFishingLeftArmEnabled;
|
||||
|
||||
[SerializeField] private float transitionWeightTimeScale = 1f;
|
||||
|
||||
public Transform CurrentTarget => _FullBodyIK.solver.leftHandEffector.target;
|
||||
// public Transform CurrentTarget => _FullBodyIK.solver.leftHandEffector.target;
|
||||
|
||||
public Transform LeftHandTransform => _LeftHandTransform;
|
||||
// public Transform LeftHandTransform => _LeftHandTransform;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_LookAtIK = GetComponent<LookAtIK>();
|
||||
_AimIK = GetComponent<AimIK>();
|
||||
_FullBodyIK = GetComponent<FullBodyBipedIK>();
|
||||
_ArmIK = GetComponent<ArmIK>();
|
||||
SetAimIK(enabled: false);
|
||||
// _AimIK = GetComponent<AimIK>();
|
||||
// _FullBodyIK = GetComponent<FullBodyBipedIK>();
|
||||
// _ArmIK = GetComponent<ArmIK>();
|
||||
// SetAimIK(enabled: false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void SetBipedIK(bool enabled)
|
||||
{
|
||||
}
|
||||
@@ -57,54 +60,54 @@ namespace NBF
|
||||
_isFishingLeftArmEnabled = enabled;
|
||||
}
|
||||
|
||||
public void SetFishingLeftArm(bool enabled, Transform target)
|
||||
{
|
||||
_isFishingLeftArmEnabled = enabled;
|
||||
_ArmIK.solver.arm.target = target;
|
||||
}
|
||||
// public void SetFishingLeftArm(bool enabled, Transform target)
|
||||
// {
|
||||
// _isFishingLeftArmEnabled = enabled;
|
||||
// _ArmIK.solver.arm.target = target;
|
||||
// }
|
||||
|
||||
public void SetBipedLeftHandIK(bool enabled, bool instant = false)
|
||||
{
|
||||
_isLeftHandEnabled = enabled;
|
||||
if (instant)
|
||||
{
|
||||
_FullBodyIK.solver.leftArmMapping.weight = (enabled ? 1f : 0f);
|
||||
}
|
||||
}
|
||||
// public void SetBipedLeftHandIK(bool enabled, bool instant = false)
|
||||
// {
|
||||
// _isLeftHandEnabled = enabled;
|
||||
// if (instant)
|
||||
// {
|
||||
// _FullBodyIK.solver.leftArmMapping.weight = (enabled ? 1f : 0f);
|
||||
// }
|
||||
// }
|
||||
|
||||
public void SetBipedRightHandIK(bool enabled, bool instant = false)
|
||||
{
|
||||
_isRightHandEnabled = enabled;
|
||||
if (instant)
|
||||
{
|
||||
_FullBodyIK.solver.rightArmMapping.weight = (enabled ? 1f : 0f);
|
||||
}
|
||||
}
|
||||
// public void SetBipedRightHandIK(bool enabled, bool instant = false)
|
||||
// {
|
||||
// _isRightHandEnabled = enabled;
|
||||
// if (instant)
|
||||
// {
|
||||
// _FullBodyIK.solver.rightArmMapping.weight = (enabled ? 1f : 0f);
|
||||
// }
|
||||
// }
|
||||
|
||||
public void SetBipedLeftHandIK(bool enabled, Transform target, bool instant = false)
|
||||
{
|
||||
_isLeftHandEnabled = enabled;
|
||||
_FullBodyIK.solver.leftHandEffector.target = target;
|
||||
if (instant)
|
||||
{
|
||||
_FullBodyIK.solver.leftArmMapping.weight = (enabled ? 1f : 0f);
|
||||
}
|
||||
}
|
||||
// public void SetBipedLeftHandIK(bool enabled, Transform target, bool instant = false)
|
||||
// {
|
||||
// _isLeftHandEnabled = enabled;
|
||||
// _FullBodyIK.solver.leftHandEffector.target = target;
|
||||
// if (instant)
|
||||
// {
|
||||
// _FullBodyIK.solver.leftArmMapping.weight = (enabled ? 1f : 0f);
|
||||
// }
|
||||
// }
|
||||
|
||||
public void SetBipedRightHandIK(bool enabled, Transform target, bool instant = false)
|
||||
{
|
||||
_isRightHandEnabled = enabled;
|
||||
_FullBodyIK.solver.rightHandEffector.target = target;
|
||||
if (instant)
|
||||
{
|
||||
_FullBodyIK.solver.rightArmMapping.weight = (enabled ? 1f : 0f);
|
||||
}
|
||||
}
|
||||
// public void SetBipedRightHandIK(bool enabled, Transform target, bool instant = false)
|
||||
// {
|
||||
// _isRightHandEnabled = enabled;
|
||||
// _FullBodyIK.solver.rightHandEffector.target = target;
|
||||
// if (instant)
|
||||
// {
|
||||
// _FullBodyIK.solver.rightArmMapping.weight = (enabled ? 1f : 0f);
|
||||
// }
|
||||
// }
|
||||
|
||||
public void SetAimIK(bool enabled)
|
||||
{
|
||||
isAimEnabled = enabled;
|
||||
}
|
||||
// public void SetAimIK(bool enabled)
|
||||
// {
|
||||
// isAimEnabled = enabled;
|
||||
// }
|
||||
|
||||
private void Update()
|
||||
{
|
||||
@@ -132,22 +135,22 @@ namespace NBF
|
||||
|
||||
private void IKUpdateHandler()
|
||||
{
|
||||
_AimIK.UpdateSolverExternal();
|
||||
// _AimIK.UpdateSolverExternal();
|
||||
_LookAtIK.UpdateSolverExternal();
|
||||
_FullBodyIK.UpdateSolverExternal();
|
||||
_FullBodyIK.solver.Update();
|
||||
_AimIK.solver.IKPositionWeight = Mathf.MoveTowards(_AimIK.solver.IKPositionWeight, isAimEnabled ? 1f : 0f,
|
||||
Time.deltaTime * transitionWeightTimeScale);
|
||||
_FullBodyIK.solver.leftArmMapping.weight = Mathf.MoveTowards(_FullBodyIK.solver.leftArmMapping.weight,
|
||||
_isLeftHandEnabled ? 1f : 0f, Time.deltaTime * transitionWeightTimeScale);
|
||||
_FullBodyIK.solver.rightArmMapping.weight = Mathf.MoveTowards(_FullBodyIK.solver.rightArmMapping.weight,
|
||||
_isRightHandEnabled ? 1f : 0f, Time.deltaTime * transitionWeightTimeScale);
|
||||
_FullBodyIK.solver.IKPositionWeight = Mathf.MoveTowards(_FullBodyIK.solver.IKPositionWeight,
|
||||
_isLeftHandEnabled ? 1f : 0f, Time.deltaTime * transitionWeightTimeScale);
|
||||
_ArmIK.solver.IKPositionWeight = Mathf.MoveTowards(_ArmIK.solver.IKPositionWeight,
|
||||
_isFishingLeftArmEnabled ? 1f : 0f, Time.deltaTime * transitionWeightTimeScale);
|
||||
_ArmIK.solver.IKRotationWeight = Mathf.MoveTowards(_ArmIK.solver.IKRotationWeight,
|
||||
_isFishingLeftArmEnabled ? 1f : 0f, Time.deltaTime * transitionWeightTimeScale);
|
||||
// _FullBodyIK.UpdateSolverExternal();
|
||||
// _FullBodyIK.solver.Update();
|
||||
// _AimIK.solver.IKPositionWeight = Mathf.MoveTowards(_AimIK.solver.IKPositionWeight, isAimEnabled ? 1f : 0f,
|
||||
// Time.deltaTime * transitionWeightTimeScale);
|
||||
// _FullBodyIK.solver.leftArmMapping.weight = Mathf.MoveTowards(_FullBodyIK.solver.leftArmMapping.weight,
|
||||
// _isLeftHandEnabled ? 1f : 0f, Time.deltaTime * transitionWeightTimeScale);
|
||||
// _FullBodyIK.solver.rightArmMapping.weight = Mathf.MoveTowards(_FullBodyIK.solver.rightArmMapping.weight,
|
||||
// _isRightHandEnabled ? 1f : 0f, Time.deltaTime * transitionWeightTimeScale);
|
||||
// _FullBodyIK.solver.IKPositionWeight = Mathf.MoveTowards(_FullBodyIK.solver.IKPositionWeight,
|
||||
// _isLeftHandEnabled ? 1f : 0f, Time.deltaTime * transitionWeightTimeScale);
|
||||
// _ArmIK.solver.IKPositionWeight = Mathf.MoveTowards(_ArmIK.solver.IKPositionWeight,
|
||||
// _isFishingLeftArmEnabled ? 1f : 0f, Time.deltaTime * transitionWeightTimeScale);
|
||||
// _ArmIK.solver.IKRotationWeight = Mathf.MoveTowards(_ArmIK.solver.IKRotationWeight,
|
||||
// _isFishingLeftArmEnabled ? 1f : 0f, Time.deltaTime * transitionWeightTimeScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user