public override void Initialize() { root = GetComponentInChildren <BodyRoot>(); joints = GetComponentsInChildren <BallJoint>(); interval = GetComponent <DecisionRequester>().DecisionPeriod; numActions = GetComponent <BehaviorParameters>().BrainParameters.NumActions; lerpActions = new float[numActions]; sliderValues = new float[numActions]; resetter = new Resetter(transform); if (fixateBodyRoot) { root.gameObject.AddComponent <FixedJoint>(); } root.Initialize(); foreach (BallJoint joint in joints) { joint.Initialize(); } Transform canvas = GetComponentInChildren <Canvas>().transform; for (int index = 0, i = 0; i < canvas.childCount; i++) { Transform tf = canvas.GetChild(i); Text text = tf.GetComponentInChildren <Text>(); text.text = joints[i].name; IndexedSlider[] s = tf.GetComponentsInChildren <IndexedSlider>(); for (int j = 0; j < 3; j++) { if (joints[i].DOF[j]) { s[j].SetIndex(index++); s[j].OnValueChange = OnSliderValueChange; } else { s[j].SetInteractable(false); } } } }
public override void Initialize() { resetter = new Resetter(transform); root = GetComponentInChildren <BodyRoot>(); joints = GetComponentsInChildren <BallJoint>(); jointObs = new List <float>(); // https://github.com/Unity-Technologies/ml-agents/issues/4180 var a = GetComponent <DecisionRequester>(); var b = GetComponent <PausableDecisionRequester>(); // demo interval = b != null ? b.DecisionPeriod : a.DecisionPeriod; numActions = GetComponent <BehaviorParameters>().BrainParameters.NumActions; lerpActions = new float[numActions]; rayObs = new List <float>(); parts = new Observables[] { Hips, Head, LeftHand, RightHand, LeftFoot, RightFoot }; opponentLayerMask = 1 << opponent.gameObject.layer; if (fixateBodyRoot) { root.gameObject.AddComponent <FixedJoint>(); } root.Initialize(); foreach (BallJoint joint in joints) { joint.Initialize(); } var detectors = GetComponentsInChildren <CollisionDetection>(); foreach (var detector in detectors) { detector.OnCollision += OnCollision; } }