mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-03 18:39:23 +00:00
Added a unity editor script to toggle ragdoll via animation on your avatar
This commit is contained in:
parent
76f9244d9c
commit
e426418806
6 changed files with 39 additions and 0 deletions
|
@ -3,7 +3,9 @@ using ABI_RC.Core.InteractionSystem;
|
|||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Systems.IK.SubSystems;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using ABI_RC.Core.Util.AssetFiltering;
|
||||
|
||||
namespace ml_prm
|
||||
{
|
||||
|
@ -46,6 +48,10 @@ namespace ml_prm
|
|||
null
|
||||
);
|
||||
|
||||
// Whitelist the toggle script
|
||||
var l_localComponentWhitelist = typeof(SharedFilter).GetField("_localComponentWhitelist", BindingFlags.NonPublic | BindingFlags.Static)!.GetValue(null) as HashSet<Type>;
|
||||
l_localComponentWhitelist!.Add(typeof(RagdollToggle));
|
||||
|
||||
MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer());
|
||||
}
|
||||
|
||||
|
|
|
@ -23,3 +23,15 @@ Optional mod's settings with [BTKUILib](https://github.com/BTK-Development/BTKUI
|
|||
* Incompatible with `Follow hips on IK override` option in AvatarMotionTweaker.
|
||||
* Not suggested to activate fly mode with enabled ragdoll state.
|
||||
* Can't be activated in worlds that don't allow flying and spawnables.
|
||||
|
||||
# Unity Editor Script
|
||||
You can also trigger the ragdoll via animations on your avatar. To do this you need to download and import the
|
||||
`ml_prm_editor_script.unitypackage` into your unity project. Then add the component `Ragdoll Toggle` anywhere inside of
|
||||
your avatar's hierarchy. Now you can animate both parameters available:
|
||||
|
||||
- **Should Override:** Whether the animation should override the toggled state of the ragdoll.
|
||||
- **Is On:** Whether the ragdoll state is On or Off (only works if `Should Override` is also On).
|
||||
|
||||

|
||||
|
||||
**Note:** In order to work the game object needs to be active and the component enabled.
|
||||
|
|
|
@ -30,6 +30,8 @@ namespace ml_prm
|
|||
Vector3 m_lastPosition = Vector3.zero;
|
||||
Vector3 m_velocity = Vector3.zero;
|
||||
|
||||
RagdollToggle m_avatarRagdollToggle = null;
|
||||
|
||||
internal RagdollController()
|
||||
{
|
||||
m_rigidBodies = new List<Rigidbody>();
|
||||
|
@ -67,6 +69,11 @@ namespace ml_prm
|
|||
|
||||
if(Settings.Hotkey && Input.GetKeyDown(KeyCode.R) && !ViewManager.Instance.isGameMenuOpen())
|
||||
SwitchRagdoll();
|
||||
|
||||
if (m_avatarRagdollToggle != null && m_avatarRagdollToggle.isActiveAndEnabled && m_avatarRagdollToggle.shouldOverride) {
|
||||
if (m_enabled != m_avatarRagdollToggle.isOn)
|
||||
SwitchRagdoll();
|
||||
}
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
|
@ -182,6 +189,8 @@ namespace ml_prm
|
|||
m_vrIK.onPostSolverUpdate.AddListener(this.OnIKPostUpdate);
|
||||
}
|
||||
|
||||
m_avatarRagdollToggle = PlayerSetup.Instance._avatar.GetComponentInChildren<RagdollToggle>(true);
|
||||
|
||||
m_avatarReady = true;
|
||||
}
|
||||
}
|
||||
|
|
12
ml_prm/RagdollToggle.cs
Normal file
12
ml_prm/RagdollToggle.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace ml_prm
|
||||
{
|
||||
public class RagdollToggle : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Whether or not is should use the isOn property to override the current Ragdoll State of the Avatar.")]
|
||||
[SerializeField] public bool shouldOverride;
|
||||
[Tooltip("Whether Ragdoll State is active or not on the Avatar. Requires shouldOverride to be true to work.")]
|
||||
[SerializeField] public bool isOn;
|
||||
}
|
||||
}
|
BIN
ml_prm/ml_prm_editor_script.unitypackage
Normal file
BIN
ml_prm/ml_prm_editor_script.unitypackage
Normal file
Binary file not shown.
BIN
ml_prm/resources/ragdoll_toggle_editor_script.png
Normal file
BIN
ml_prm/resources/ragdoll_toggle_editor_script.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.2 KiB |
Loading…
Add table
Add a link
Reference in a new issue