mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-03 18:39:23 +00:00
Custom IK limits
This commit is contained in:
parent
19032650a3
commit
de2cd0fd56
3 changed files with 26 additions and 7 deletions
|
@ -1,5 +1,4 @@
|
||||||
using ABI_RC.Core.Player;
|
using ABI_RC.Core.Player;
|
||||||
using ABI_RC.Core.Savior;
|
|
||||||
using ABI_RC.Systems.IK;
|
using ABI_RC.Systems.IK;
|
||||||
using ABI_RC.Systems.IK.SubSystems;
|
using ABI_RC.Systems.IK.SubSystems;
|
||||||
using ABI_RC.Systems.MovementSystem;
|
using ABI_RC.Systems.MovementSystem;
|
||||||
|
@ -49,6 +48,8 @@ namespace ml_amt
|
||||||
|
|
||||||
Vector3 m_massCenter = Vector3.zero;
|
Vector3 m_massCenter = Vector3.zero;
|
||||||
|
|
||||||
|
Transform m_ikLimits = null;
|
||||||
|
|
||||||
readonly List<AvatarParameter> m_parameters = null;
|
readonly List<AvatarParameter> m_parameters = null;
|
||||||
|
|
||||||
internal MotionTweaker()
|
internal MotionTweaker()
|
||||||
|
@ -92,6 +93,8 @@ namespace ml_amt
|
||||||
m_groundedRaw = MovementSystem.Instance.IsGroundedRaw();
|
m_groundedRaw = MovementSystem.Instance.IsGroundedRaw();
|
||||||
m_moving = !Mathf.Approximately(MovementSystem.Instance.movementVector.magnitude, 0f);
|
m_moving = !Mathf.Approximately(MovementSystem.Instance.movementVector.magnitude, 0f);
|
||||||
|
|
||||||
|
UpdateIKLimits();
|
||||||
|
|
||||||
if(m_avatarHips != null)
|
if(m_avatarHips != null)
|
||||||
{
|
{
|
||||||
Vector4 l_hipsToPoint = (PlayerSetup.Instance.transform.GetMatrix().inverse * m_avatarHips.GetMatrix()) * ms_pointVector;
|
Vector4 l_hipsToPoint = (PlayerSetup.Instance.transform.GetMatrix().inverse * m_avatarHips.GetMatrix()) * ms_pointVector;
|
||||||
|
@ -129,6 +132,7 @@ namespace ml_amt
|
||||||
m_hipsToPlayer = Vector3.zero;
|
m_hipsToPlayer = Vector3.zero;
|
||||||
m_avatarHips = null;
|
m_avatarHips = null;
|
||||||
m_massCenter = Vector3.zero;
|
m_massCenter = Vector3.zero;
|
||||||
|
m_ikLimits = null;
|
||||||
m_parameters.Clear();
|
m_parameters.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,6 +150,10 @@ namespace ml_amt
|
||||||
m_parameters.Add(new AvatarParameter(AvatarParameter.ParameterType.Moving, PlayerSetup.Instance.animatorManager));
|
m_parameters.Add(new AvatarParameter(AvatarParameter.ParameterType.Moving, PlayerSetup.Instance.animatorManager));
|
||||||
m_parameters.RemoveAll(p => !p.IsValid());
|
m_parameters.RemoveAll(p => !p.IsValid());
|
||||||
|
|
||||||
|
// Avatar custom IK limits
|
||||||
|
m_ikLimits = PlayerSetup.Instance._avatar.transform.Find("[IKLimits]");
|
||||||
|
UpdateIKLimits();
|
||||||
|
|
||||||
// Apply VRIK tweaks
|
// Apply VRIK tweaks
|
||||||
if(m_vrIk != null)
|
if(m_vrIk != null)
|
||||||
{
|
{
|
||||||
|
@ -276,11 +284,13 @@ namespace ml_amt
|
||||||
// Settings
|
// Settings
|
||||||
internal void SetCrouchLimit(float p_value)
|
internal void SetCrouchLimit(float p_value)
|
||||||
{
|
{
|
||||||
PlayerSetup.Instance.avatarCrouchLimit = Mathf.Max(Mathf.Clamp01(p_value), PlayerSetup.Instance.avatarProneLimit);
|
if(m_ikLimits == null)
|
||||||
|
PlayerSetup.Instance.avatarCrouchLimit = Mathf.Max(Mathf.Clamp01(p_value), PlayerSetup.Instance.avatarProneLimit);
|
||||||
}
|
}
|
||||||
internal void SetProneLimit(float p_value)
|
internal void SetProneLimit(float p_value)
|
||||||
{
|
{
|
||||||
PlayerSetup.Instance.avatarProneLimit = Mathf.Min(Mathf.Clamp01(p_value), PlayerSetup.Instance.avatarCrouchLimit);
|
if(m_ikLimits == null)
|
||||||
|
PlayerSetup.Instance.avatarProneLimit = Mathf.Min(Mathf.Clamp01(p_value), PlayerSetup.Instance.avatarCrouchLimit);
|
||||||
}
|
}
|
||||||
internal void SetIKOverrideFly(bool p_state)
|
internal void SetIKOverrideFly(bool p_state)
|
||||||
{
|
{
|
||||||
|
@ -310,6 +320,16 @@ namespace ml_amt
|
||||||
return ((m_avatarScale > 0f) ? (PlayerSetup.Instance._avatar.transform.localScale.y / m_avatarScale) : 0f);
|
return ((m_avatarScale > 0f) ? (PlayerSetup.Instance._avatar.transform.localScale.y / m_avatarScale) : 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateIKLimits()
|
||||||
|
{
|
||||||
|
if(m_ikLimits != null)
|
||||||
|
{
|
||||||
|
Vector3 l_values = m_ikLimits.localPosition;
|
||||||
|
PlayerSetup.Instance.avatarCrouchLimit = Mathf.Max(Mathf.Clamp01(l_values.x), Mathf.Clamp01(l_values.y));
|
||||||
|
PlayerSetup.Instance.avatarProneLimit = Mathf.Min(Mathf.Clamp01(l_values.x), Mathf.Clamp01(l_values.y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Parameters access
|
// Parameters access
|
||||||
public float GetUpright() => PlayerSetup.Instance.avatarUpright;
|
public float GetUpright() => PlayerSetup.Instance.avatarUpright;
|
||||||
public bool GetGroundedRaw() => m_groundedRaw;
|
public bool GetGroundedRaw() => m_groundedRaw;
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
using System.Reflection;
|
[assembly: MelonLoader.MelonInfo(typeof(ml_amt.AvatarMotionTweaker), "AvatarMotionTweaker", "1.2.9", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
|
||||||
|
|
||||||
[assembly: MelonLoader.MelonInfo(typeof(ml_amt.AvatarMotionTweaker), "AvatarMotionTweaker", "1.2.9", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
|
|
||||||
[assembly: MelonLoader.MelonGame(null, "ChilloutVR")]
|
[assembly: MelonLoader.MelonGame(null, "ChilloutVR")]
|
||||||
[assembly: MelonLoader.MelonOptionalDependencies("ml_prm", "ml_pmc")]
|
[assembly: MelonLoader.MelonOptionalDependencies("ml_prm", "ml_pmc")]
|
||||||
[assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
[assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
||||||
|
|
|
@ -37,4 +37,5 @@ Available additional parameters for AAS animator:
|
||||||
* Note: Can be set as local-only (not synced) if starts with `#` character.
|
* Note: Can be set as local-only (not synced) if starts with `#` character.
|
||||||
|
|
||||||
Additional mod's behaviour:
|
Additional mod's behaviour:
|
||||||
* Overrides and fixes IK behaviour in 4PT mode (head, hands and hips).
|
* Overrides and fixes IK behaviour in 4PT mode (head, hands and hips).
|
||||||
|
* Avatars can have controlled IK crouch and prone limits. For that create `[IKLimits]` GameObject parented to avatar's root. Its local X and Y positions will be used as crouch and prone limits respectively and can be changed via animations. Values should be in range of [0;1].
|
Loading…
Add table
Add a link
Reference in a new issue