enable the script below to be able to handle multiple 'other' rigs. using…
- User
enable the script below to be able to handle multiple 'other' rigs.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class CombineBoners : MonoBehaviour { void Snap_Bones(Transform bone) { //SEARCH THE 'Base_Bones' LIST FOR A BONE THE SAME NAME AS 'bone.gameobject' for (int i = 0; i < Base_Bones.Count; i++) { if (Base_Bones[i].name == bone.name) {
code//RESIZE 'OTHER' BONE TO MATCH BASE BONE. bone.localScale = Base_Bones[i].localScale; //PARENT 'OTHER' BONE TO BASE BONE. bone.parent = Base_Bones[i]; //ROTATE 'OTHER' BONE TO MATCH BASE BONE. bone.rotation = Base_Bones[i].rotation; //POSITION 'OTHER' BONE TO MATCH BASE BONE. bone.position = Base_Bones[i].position; } } } public List<Transform> Base_Bones = new List<Transform>(); public List<Transform> Other_Bones = new List<Transform>(); public GameObject Base_Rig; public GameObject Other_Rig; public void Start() { //GET ALL BASE RIG BONES & ORGANIZE THEM IN A LIST. ///////////////////////////////////////////////////////////////////////// foreach (Transform Bone in Base_Rig.GetComponentsInChildren<Transform>()) { Base_Bones.Add(Bone); } ///////////////////////////////////////////////////////////////////////// //GET ALL OTHER RIG BONES & ORGANIZE THEM IN A LIST. ///////////////////////////////////////////////////////////////////////// foreach (Transform Bone in Other_Rig.GetComponentsInChildren<Transform>()) { Other_Bones.Add(Bone); } ///////////////////////////////////////////////////////////////////////////////////// //SNAP OTHER BONES TO BASE RIG BONES | LOCATION | ROTATION | SCALE | TRANSFORM PARENT ///////////////////////////////////////////////////////////////////////////////////// for (int i = 0; i < Other_Bones.Count; i++) { Snap_Bones(Other_Bones[i]); } } - Assistant