GhostPos SetupVRIK(GameObject avatar) { GameObject headTarget, leftHandTarget, rightHandTarget; headTarget = new GameObject(); leftHandTarget = (GameObject)Instantiate(Resources.Load("hand"), new Vector3(0, 0, 0), new Quaternion(0, 0, 0, 0)); rightHandTarget = (GameObject)Instantiate(Resources.Load("hand"), new Vector3(0, 0, 0), new Quaternion(0, 0, 0, 0)); GhostPos ghostPos = new GhostPos(); ghostPos.head = headTarget.transform; ghostPos.left = leftHandTarget.transform; ghostPos.right = rightHandTarget.transform; headTarget.transform.position = new Vector3(0f, 1.5f, 0f); leftHandTarget.transform.position = new Vector3(-0.5f, 0.8f, 0f); rightHandTarget.transform.position = new Vector3(0.5f, 0.8f, 0f); var vrIK = avatar.AddComponent <RootMotion.FinalIK.VRIK>(); vrIK.AutoDetectReferences(); // NullReferenceエラーがでるので初期化しておく vrIK.solver.leftArm.stretchCurve = new AnimationCurve(); vrIK.solver.rightArm.stretchCurve = new AnimationCurve(); // 頭や腕のターゲット設定 vrIK.solver.spine.headTarget = headTarget.transform; vrIK.solver.leftArm.target = leftHandTarget.transform; vrIK.solver.rightArm.target = rightHandTarget.transform; // 歩幅の設定 vrIK.solver.locomotion.footDistance = 0.1f; return(ghostPos); }
int run(GhostPos ghostPos, int progress, int index) { if (index == 0) { Debug.Log("no record"); return(-1); } ; var motion = record.MotionRecords[index - 1]; if (motion.Count - 35 <= progress) { Debug.Log("motion end"); return(-1); } var pose = motion[progress++]; var arr = pose.Split(','); int i = 0; ghostPos.head.position = new Vector3(float.Parse(arr[i++]), float.Parse(arr[i++]), float.Parse(arr[i++])); ghostPos.left.position = new Vector3(float.Parse(arr[i++]), float.Parse(arr[i++]), float.Parse(arr[i++])); ghostPos.right.position = new Vector3(float.Parse(arr[i++]), float.Parse(arr[i++]), float.Parse(arr[i++])); ghostPos.head.rotation = new Quaternion(float.Parse(arr[i++]), float.Parse(arr[i++]), float.Parse(arr[i++]), float.Parse(arr[i++])); ghostPos.left.rotation = new Quaternion(float.Parse(arr[i++]), float.Parse(arr[i++]), float.Parse(arr[i++]), float.Parse(arr[i++])); ghostPos.right.rotation = new Quaternion(float.Parse(arr[i++]), float.Parse(arr[i++]), float.Parse(arr[i++]), float.Parse(arr[i++])); return(progress); }
void RadarHandler(string sender, GhostPos data) { string location = ""; print(data.room); switch (data.room) { case 1: { location = "Kitchen"; break; } case 2: { location = "Dining"; break; } case 3: { location = "Nursery"; break; } case 4: { location = "Closet"; break; } case 5: { location = "SRA"; break; } case 6: { location = "Hallway"; break; } case 7: { location = "SRB"; break; } case 8: { location = "Bathroom"; break; } case 9: { location = "RUC"; break; } case 10: { location = "Bedroom"; break; } case 11: { location = "Lab"; break; } case 12: { location = "Library"; break; } default: break; } print(location); GameObject radarGhost = GameObject.Find(location); Debug.Log(radarGhost); mke.EnableRadar(); r.UpdateRadar(radarGhost.transform.position); mke.manualClose = false; Invoke("DelayedDisableMap", 5f); }