Created
December 15, 2019 03:36
-
-
Save sasame/795d8873a508d6bf2ebb678019d7f5cd to your computer and use it in GitHub Desktop.
LaHumanRigに対してこのようなスクリプトをつけて、エフェクタを操作できます。
This file contains hidden or 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 System.Collections; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| using LaHuman; | |
| public class YBRigControl : MonoBehaviour | |
| { | |
| LaHumanRig _rig; | |
| BodyTransformsData _body = new BodyTransformsData(); | |
| Dictionary<string, GameObject> _dicObj = new Dictionary<string, GameObject>(); | |
| // Start is called before the first frame update | |
| void Start() | |
| { | |
| _rig = GetComponent<LaHumanRig>(); | |
| _rig.BodyTransforms.CopyTo(_body); | |
| _dicObj["Hips"] = createEffector(_body.HipsEffector); | |
| _dicObj["LeftHand"] = createEffector(_body.LeftHandEffector); | |
| _dicObj["RightHand"] = createEffector(_body.RightHandEffector); | |
| _dicObj["LeftFoot"] = createEffector(_body.LeftFootEffector); | |
| _dicObj["RightFoot"] = createEffector(_body.RightFootEffector); | |
| } | |
| GameObject createEffector(Vector3 pos) | |
| { | |
| GameObject o = GameObject.CreatePrimitive(PrimitiveType.Sphere); | |
| o.transform.localScale = Vector3.one * 0.1f; | |
| o.transform.position = pos; | |
| o.transform.SetParent(BrickCreator.Inst.transform); | |
| var r = o.AddComponent<Rigidbody>(); | |
| r.isKinematic = true; | |
| return o; | |
| } | |
| // Update is called once per frame | |
| void Update() | |
| { | |
| _body.HipsEffector = _dicObj["Hips"].transform.position; | |
| _body.LeftHandEffector = _dicObj["LeftHand"].transform.position; | |
| _body.RightHandEffector = _dicObj["RightHand"].transform.position; | |
| _body.LeftFootEffector = _dicObj["LeftFoot"].transform.position; | |
| _body.RightFootEffector = _dicObj["RightFoot"].transform.position; | |
| _rig.BodyTransforms.ApplyPreset(_body); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment