From 854ee7481fbe4604e5311bb9f0f41909d8786af5 Mon Sep 17 00:00:00 2001 From: yoship1639 Date: Wed, 10 Jun 2020 22:04:35 +0900 Subject: [PATCH 1/2] Fix: SpringBone LateUpdate to FixedUpdate --- Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringBone.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringBone.cs b/Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringBone.cs index 8bed39d2f..0bc5fa8a3 100644 --- a/Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringBone.cs +++ b/Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringBone.cs @@ -281,7 +281,7 @@ namespace VRM } List m_colliderList = new List(); - void LateUpdate() + void FixedUpdate() { if (m_verlet == null || m_verlet.Count == 0) { @@ -312,8 +312,8 @@ namespace VRM } } - var stiffness = m_stiffnessForce * Time.deltaTime; - var external = m_gravityDir * (m_gravityPower * Time.deltaTime); + var stiffness = m_stiffnessForce * Time.fixedDeltaTime; + var external = m_gravityDir * (m_gravityPower * Time.fixedDeltaTime); foreach (var verlet in m_verlet) { From 6027b800c9076686f1905c51b889ec410be87a95 Mon Sep 17 00:00:00 2001 From: yoship1639 Date: Mon, 15 Jun 2020 19:48:35 +0900 Subject: [PATCH 2/2] Fix: Selectable LateUpdate or FIxedUpdate --- .../Scripts/SpringBone/VRMSpringBone.cs | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringBone.cs b/Assets/VRM/UniVRM/Scripts/SpringBone/VRMSpringBone.cs index 0bc5fa8a3..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 FixedUpdate() + private void UpdateProcess(float deltaTime) { if (m_verlet == null || m_verlet.Count == 0) { @@ -312,8 +336,8 @@ namespace VRM } } - var stiffness = m_stiffnessForce * Time.fixedDeltaTime; - var external = m_gravityDir * (m_gravityPower * Time.fixedDeltaTime); + var stiffness = m_stiffnessForce * deltaTime; + var external = m_gravityDir * (m_gravityPower * deltaTime); foreach (var verlet in m_verlet) {