Created
January 16, 2020 12:53
-
-
Save but80/7fbbb2461406116cd6dd44cf198b628b to your computer and use it in GitHub Desktop.
UniVRMでインポートしたモデルがPhysics.gravityの方向を考慮してくれないのを修正するコンポーネント(モデルのルートにアタッチしてね)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using VRM; | |
public class VRMGravityCorrector : MonoBehaviour | |
{ | |
VRMSpringBone[] springBones; | |
void Start() | |
{ | |
springBones = GetComponentsInChildren<VRMSpringBone>(); | |
} | |
void Update() | |
{ | |
var g = Physics.gravity / 9.81f; | |
foreach (var bone in springBones) | |
{ | |
bone.m_gravityDir = g; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment