Skip to content

Instantly share code, notes, and snippets.

@but80
Created January 16, 2020 12:53
Show Gist options
  • Save but80/7fbbb2461406116cd6dd44cf198b628b to your computer and use it in GitHub Desktop.
Save but80/7fbbb2461406116cd6dd44cf198b628b to your computer and use it in GitHub Desktop.
UniVRMでインポートしたモデルがPhysics.gravityの方向を考慮してくれないのを修正するコンポーネント(モデルのルートにアタッチしてね)
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