public ArmMimic CreateArm(ArmMimic.ArmSide WhichSide, VRObjectMimic Tracker, VRObjectMimic Controller) { //Create an Arm Prefab ArmMimic newArm = GameObject.Instantiate <GameObject>(Resources.Load <GameObject>("Arm Mimic Prefab")).GetComponent <ArmMimic>(); newArm.transform.SetParent(transform); //Initialize the arm prefab (handing in the side and connector points) newArm.Initialize(WhichSide, GetShoulder(WhichSide), Tracker, Controller); //Keep track of this as our Left/Right arm? AttachArmToOurBody(WhichSide, newArm); return(newArm); }
public void AttachArmToOurBody(ArmMimic.ArmSide WhichSide, ArmMimic Arm) { if (WhichSide == ArmMimic.ArmSide.Left) { LeftArm = Arm; LeftArm.transform.SetParent(LeftShoulder.transform); LeftArm.transform.localPosition = Arm.transform.right * -.5f; LeftArm.MirrorKeyArmElements(); } else { RightArm = Arm; RightArm.transform.SetParent(RightShoulder.transform); RightArm.transform.localPosition = Arm.transform.right * .5f; } }
public ArmMimic AccessArm(ArmMimic.ArmSide WhichSide) { if (WhichSide == ArmMimic.ArmSide.Left) { if (LeftArm != null) { return(LeftArm); } } else { if (LeftArm != null) { return(LeftArm); } } //If this code has reached you, you can add //return null; //And comment the exception out. This shouldn't happen, but we know how code & releases work. throw new System.Exception("Arm Requested [" + WhichSide.ToString() + "] was not added or configured according to the BodyMimic\nThis behavior will attempt an autosetup on the requested arm in the future"); }