mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-03 10:29:22 +00:00
Independent movement scale and pose transitions
This commit is contained in:
parent
f364d6d2aa
commit
2c118f20ba
4 changed files with 30 additions and 53 deletions
|
@ -4,8 +4,8 @@ Merged set of MelonLoader mods for ChilloutVR.
|
|||
| Full name | Short name | Latest version | Available in [CVRMA](https://github.com/knah/CVRMelonAssistant) | Current Status | Notes |
|
||||
|-----------|------------|----------------|-----------------------------------------------------------------|----------------|-------|
|
||||
| Avatar Change Info | ml_aci | 1.0.2 | Yes | Working |
|
||||
| Avatar Motion Tweaker | ml_amt | 1.0.9 | On review | Working |
|
||||
| Avatar Motion Tweaker | ml_amt | 1.1.0 | On review | Working |
|
||||
| Desktop Reticle Switch | ml_drs | 1.0.0 | Yes | Working |
|
||||
| Four Point Tracking | ml_fpt | 1.0.4 | Yes | Working |
|
||||
| Four Point Tracking | ml_fpt | 1.0.5 | On review | Working |
|
||||
| Leap Motion Extension | ml_lme | 1.1.8 | Yes | Working |
|
||||
| Server Connection Info | ml_sci | 1.0.1 | Yes | Working |
|
||||
|
|
|
@ -42,6 +42,7 @@ namespace ml_amt
|
|||
|
||||
VRIK m_vrIk = null;
|
||||
float m_locomotionWeight = 1f; // Original weight
|
||||
float m_avatarScale = 1f; // Instantiated scale
|
||||
|
||||
bool m_avatarReady = false;
|
||||
bool m_compatibleAvatar = false;
|
||||
|
@ -77,8 +78,9 @@ namespace ml_amt
|
|||
// Update upright
|
||||
Matrix4x4 l_hmdMatrix = PlayerSetup.Instance.transform.GetMatrix().inverse * (PlayerSetup.Instance._inVr ? PlayerSetup.Instance.vrHeadTracker.transform.GetMatrix() : PlayerSetup.Instance.desktopCameraRig.transform.GetMatrix());
|
||||
float l_currentHeight = Mathf.Clamp((l_hmdMatrix * ms_pointVector).y, 0f, float.MaxValue);
|
||||
float l_avatarViewHeight = Mathf.Clamp(PlayerSetup.Instance.GetViewPointHeight() * PlayerSetup.Instance._avatar.transform.localScale.y, 0f, float.MaxValue);
|
||||
m_upright = Mathf.Clamp((((l_currentHeight > 0f) && (l_avatarViewHeight > 0f)) ? (l_currentHeight / l_avatarViewHeight) : 0f), 0f, 1f);
|
||||
float l_avatarScale = (m_avatarScale > 0f) ? (PlayerSetup.Instance._avatar.transform.localScale.y / m_avatarScale) : 0f;
|
||||
float l_avatarViewHeight = Mathf.Clamp(PlayerSetup.Instance.GetViewPointHeight() * l_avatarScale, 0f, float.MaxValue);
|
||||
m_upright = Mathf.Clamp(((l_avatarViewHeight > 0f) ? (l_currentHeight / l_avatarViewHeight) : 0f), 0f, 1f);
|
||||
PoseState l_poseState = (m_upright <= m_proneLimit) ? PoseState.Proning : ((m_upright <= m_crouchLimit) ? PoseState.Crouching : PoseState.Standing);
|
||||
|
||||
if((m_vrIk != null) && m_vrIk.enabled)
|
||||
|
@ -92,43 +94,23 @@ namespace ml_amt
|
|||
ms_rootVelocity.SetValue(m_vrIk.solver, Vector3.zero);
|
||||
}
|
||||
|
||||
if(m_poseTransitions && !m_compatibleAvatar && !PlayerSetup.Instance.fullBodyActive)
|
||||
if(m_adjustedMovement)
|
||||
{
|
||||
switch(l_poseState)
|
||||
MovementSystem.Instance.ChangeCrouch(l_poseState == PoseState.Crouching);
|
||||
MovementSystem.Instance.ChangeProne(l_poseState == PoseState.Proning);
|
||||
|
||||
if(!m_poseTransitions)
|
||||
{
|
||||
case PoseState.Standing:
|
||||
{
|
||||
if(m_adjustedMovement)
|
||||
{
|
||||
MovementSystem.Instance.ChangeCrouch(false); //
|
||||
MovementSystem.Instance.ChangeProne(false); // Affects movement speed
|
||||
}
|
||||
PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool("Crouching", false); //
|
||||
PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool("Prone", false); // Force to stop transitioning to standing locomotion while moving
|
||||
}
|
||||
break;
|
||||
|
||||
case PoseState.Crouching:
|
||||
{
|
||||
if(m_adjustedMovement)
|
||||
MovementSystem.Instance.ChangeCrouch(true);
|
||||
|
||||
PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool("Crouching", true);
|
||||
PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool("Prone", false);
|
||||
}
|
||||
break;
|
||||
|
||||
case PoseState.Proning:
|
||||
{
|
||||
if(m_adjustedMovement)
|
||||
MovementSystem.Instance.ChangeProne(true);
|
||||
|
||||
PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool("Crouching", false);
|
||||
PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool("Prone", true);
|
||||
}
|
||||
break;
|
||||
PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool("Crouching", false);
|
||||
PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool("Prone", false);
|
||||
}
|
||||
}
|
||||
|
||||
if(m_poseTransitions)
|
||||
{
|
||||
PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool("Crouching", (l_poseState == PoseState.Crouching) && !m_compatibleAvatar && !PlayerSetup.Instance.fullBodyActive);
|
||||
PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool("Prone", (l_poseState == PoseState.Proning) && !m_compatibleAvatar && !PlayerSetup.Instance.fullBodyActive);
|
||||
}
|
||||
}
|
||||
|
||||
m_poseState = l_poseState;
|
||||
|
@ -174,15 +156,16 @@ namespace ml_amt
|
|||
|
||||
public void OnAvatarClear()
|
||||
{
|
||||
m_vrIk = null;
|
||||
m_avatarReady = false;
|
||||
m_compatibleAvatar = false;
|
||||
m_vrIk = null;
|
||||
m_poseState = PoseState.Standing;
|
||||
m_parameters.Clear();
|
||||
m_customCrouchLimit = false;
|
||||
m_customProneLimit = false;
|
||||
m_customLocomotionOffset = false;
|
||||
m_locomotionOffset = Vector3.zero;
|
||||
m_avatarScale = 1f;
|
||||
m_parameters.Clear();
|
||||
}
|
||||
|
||||
public void OnSetupAvatarGeneral()
|
||||
|
@ -215,6 +198,7 @@ namespace ml_amt
|
|||
}
|
||||
|
||||
m_compatibleAvatar = m_parameters.Exists(p => p.m_name.Contains("Upright"));
|
||||
m_avatarScale = Mathf.Abs(PlayerSetup.Instance._avatar.transform.localScale.y);
|
||||
|
||||
Transform l_customTransform = PlayerSetup.Instance._avatar.transform.Find("CrouchLimit");
|
||||
m_customCrouchLimit = (l_customTransform != null);
|
||||
|
@ -278,13 +262,8 @@ namespace ml_amt
|
|||
{
|
||||
m_poseTransitions = p_state;
|
||||
|
||||
if(!m_poseTransitions && m_avatarReady && !m_compatibleAvatar && PlayerSetup.Instance._inVr)
|
||||
if(!m_poseTransitions && m_avatarReady && PlayerSetup.Instance._inVr)
|
||||
{
|
||||
if(m_adjustedMovement)
|
||||
{
|
||||
MovementSystem.Instance.ChangeCrouch(false);
|
||||
MovementSystem.Instance.ChangeProne(false);
|
||||
}
|
||||
PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool("Crouching", false);
|
||||
PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool("Prone", false);
|
||||
}
|
||||
|
@ -293,7 +272,7 @@ namespace ml_amt
|
|||
{
|
||||
m_adjustedMovement = p_state;
|
||||
|
||||
if(!m_adjustedMovement && m_poseTransitions && m_avatarReady && !m_compatibleAvatar && PlayerSetup.Instance._inVr)
|
||||
if(!m_adjustedMovement && m_avatarReady && PlayerSetup.Instance._inVr)
|
||||
{
|
||||
MovementSystem.Instance.ChangeCrouch(false);
|
||||
MovementSystem.Instance.ChangeProne(false);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyTitle("AvatarMotionTweaker")]
|
||||
[assembly: AssemblyVersion("1.0.9")]
|
||||
[assembly: AssemblyFileVersion("1.0.9")]
|
||||
[assembly: AssemblyVersion("1.1.0")]
|
||||
[assembly: AssemblyFileVersion("1.1.0")]
|
||||
|
||||
[assembly: MelonLoader.MelonInfo(typeof(ml_amt.AvatarMotionTweaker), "AvatarMotionTweaker", "1.0.9", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
|
||||
[assembly: MelonLoader.MelonInfo(typeof(ml_amt.AvatarMotionTweaker), "AvatarMotionTweaker", "1.1.0", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
|
||||
[assembly: MelonLoader.MelonGame(null, "ChilloutVR")]
|
||||
[assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
||||
[assembly: MelonLoader.MelonPlatformDomain(MelonLoader.MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
|
@ -20,19 +20,17 @@ Available mod's settings in `Settings - Implementation - Avatar Motion Tweaker`:
|
|||
* **Pose transitions:** allows regular avatars animator to transit in crouch/prone states; default value - `true`.
|
||||
* Note: Avatar is considered as regular if its AAS animator doesn't have `Upright` parameter.
|
||||
* **Adjusted pose movement speed:** scales movement speed upon crouching/proning; default value - `true`.
|
||||
* Note: Requires enabled `Pose transitions` option.
|
||||
|
||||
Available additional parameters for AAS animator:
|
||||
* **`Upright`:** defines linear coefficient between current viewpoint height and avatar's viewpoint height; float, range - [0.0, 1.0].
|
||||
* Note: Can be set as local-only (not synced) if starts with `#` character.
|
||||
* Note: Defining this parameter in AAS animator will consider avatar as compatible with mod.
|
||||
* Note: Can't be used for transitions between poses in desktop mode. In desktop mode its value is driven by avatar animations. Use `CVR Parameter Stream` for detecting desktop/VR modes and change AAS animator transitions accordingly.
|
||||
* **`GroundedRaw`:** defines instant grounding state of player instead of delayed default parameter `Grounded`.
|
||||
* Note: Can be set as local-only (not synced) if starts with `#` character.
|
||||
|
||||
Additional avatars tweaks:
|
||||
* If avatar has child object with name `LocomotionOffset` its local position will be used for offsetting VRIK locomotion center.
|
||||
* If avatar has child object with name `LocomotionOffset` its local position will be used for offsetting VRIK locomotion mass center.
|
||||
|
||||
# Notes
|
||||
* Usage of `Upright` parameter for transition between poses (standing/crouching/proning) in desktop mode is useless, because in this case your animations are updating value of `Upright` parameter, not the other way around.
|
||||
* **Adjusted pose movement speed** option isn't applied to compatible avatars, in progress.
|
||||
* Please, keep your avatars' root object at identity scale. Thank you.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue