diff --git a/Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringBone.cs b/Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringBone.cs index 8bed39d2f..0f40bcb26 100644 --- a/Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringBone.cs +++ b/Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringBone.cs @@ -48,6 +48,14 @@ namespace VRM [SerializeField] public VRMSpringBoneColliderGroup[] ColliderGroups; + public enum SpringBoneUpdateType + { + LateUpdate, + FixedUpdate, + } + [SerializeField] + public SpringBoneUpdateType m_updateType = SpringBoneUpdateType.LateUpdate; + /// /// /// original from @@ -274,6 +282,22 @@ namespace VRM } } + void LateUpdate() + { + if (m_updateType == SpringBoneUpdateType.LateUpdate) + { + UpdateProcess(Time.deltaTime); + } + } + + void FixedUpdate() + { + if (m_updateType == SpringBoneUpdateType.FixedUpdate) + { + UpdateProcess(Time.fixedDeltaTime); + } + } + public struct SphereCollider { public Vector3 Position; @@ -281,7 +305,7 @@ namespace VRM } List m_colliderList = new List(); - void LateUpdate() + private void UpdateProcess(float deltaTime) { if (m_verlet == null || m_verlet.Count == 0) { @@ -312,8 +336,8 @@ namespace VRM } } - var stiffness = m_stiffnessForce * Time.deltaTime; - var external = m_gravityDir * (m_gravityPower * Time.deltaTime); + var stiffness = m_stiffnessForce * deltaTime; + var external = m_gravityDir * (m_gravityPower * deltaTime); foreach (var verlet in m_verlet) {