void Start() { _agent = GetComponent <StyleTransfer002Agent>(); _master = GetComponent <StyleTransfer002Master>(); // _brain = FindObjectsOfType<Brain>().First(x=>x.name=="TrainerBrain"); _academy = FindObjectOfType <Academy>(); }
public void OnInitializeAgent() { Time.fixedDeltaTime = FixedDeltaTime; _waitingForAnimation = true; _decisionRequester = GetComponent<DecisionRequester>(); BodyParts = new List<BodyPart002> (); BodyPart002 root = null; foreach (var t in GetComponentsInChildren<Transform>()) { if (BodyConfig.GetBodyPartGroup(t.name) == BodyHelper002.BodyPartGroup.None) continue; var bodyPart = new BodyPart002{ Rigidbody = t.GetComponent<Rigidbody>(), Transform = t, Name = t.name, Group = BodyConfig.GetBodyPartGroup(t.name), }; if (bodyPart.Group == BodyConfig.GetRootBodyPart()) root = bodyPart; bodyPart.Root = root; bodyPart.Init(); BodyParts.Add(bodyPart); } var partCount = BodyParts.Count; Muscles = new List<Muscle002> (); var muscles = GetComponentsInChildren<ConfigurableJoint>(); ConfigurableJoint rootConfigurableJoint = null; var ragDoll = GetComponent<RagDoll002>(); foreach (var m in muscles) { var maximumForce = ragDoll.MusclePowers.First(x=>x.Muscle == m.name).PowerVector; // maximumForce *= 2f; var muscle = new Muscle002{ Rigidbody = m.GetComponent<Rigidbody>(), Transform = m.GetComponent<Transform>(), ConfigurableJoint = m, Name = m.name, Group = BodyConfig.GetMuscleGroup(m.name), MaximumForce = maximumForce }; if (muscle.Group == BodyConfig.GetRootMuscle()) rootConfigurableJoint = muscle.ConfigurableJoint; muscle.RootConfigurableJoint = rootConfigurableJoint; muscle.Init(); Muscles.Add(muscle); } var spawnableEnv = GetComponentInParent<SpawnableEnv>(); _localStyleAnimator = spawnableEnv.gameObject.GetComponentInChildren<StyleTransfer002Animator>(); _styleAnimator = _localStyleAnimator.GetFirstOfThisAnim(); // _styleAnimator = _localStyleAnimator; _muscleAnimator = _styleAnimator; _agent = GetComponent<StyleTransfer002Agent>(); // _trainerAgent = GetComponent<StyleTransfer002TrainerAgent>(); // _brain = FindObjectsOfType<Brain>().First(x=>x.name=="LearnFromMocapBrain"); IsInferenceMode = !Academy.Instance.IsCommunicatorOn; }
void Start() { Time.fixedDeltaTime = FixedDeltaTime; _waitingForAnimation = true; BodyParts = new List <BodyPart002> (); BodyPart002 root = null; foreach (var t in GetComponentsInChildren <Transform>()) { if (BodyHelper002.GetBodyPartGroup(t.name) == BodyHelper002.BodyPartGroup.None) { continue; } var bodyPart = new BodyPart002 { Rigidbody = t.GetComponent <Rigidbody>(), Transform = t, Name = t.name, Group = BodyHelper002.GetBodyPartGroup(t.name), }; if (bodyPart.Group == BodyHelper002.BodyPartGroup.Hips) { root = bodyPart; } bodyPart.Root = root; bodyPart.Init(); BodyParts.Add(bodyPart); } var partCount = BodyParts.Count; Muscles = new List <Muscle002> (); var muscles = GetComponentsInChildren <ConfigurableJoint>(); ConfigurableJoint rootConfigurableJoint = null; var ragDoll = GetComponent <RagDoll002>(); foreach (var m in muscles) { var maximumForce = ragDoll.MusclePowers.First(x => x.Muscle == m.name).PowerVector; // maximumForce *= 2f; var muscle = new Muscle002 { Rigidbody = m.GetComponent <Rigidbody>(), Transform = m.GetComponent <Transform>(), ConfigurableJoint = m, Name = m.name, Group = BodyHelper002.GetMuscleGroup(m.name), MaximumForce = maximumForce }; if (muscle.Group == BodyHelper002.MuscleGroup.Hips) { rootConfigurableJoint = muscle.ConfigurableJoint; } muscle.RootConfigurableJoint = rootConfigurableJoint; muscle.Init(); Muscles.Add(muscle); } _muscleAnimator = FindObjectOfType <StyleTransfer002Animator>(); _agent = GetComponent <StyleTransfer002Agent>(); // _trainerAgent = GetComponent<StyleTransfer002TrainerAgent>(); _brain = FindObjectsOfType <Brain>().First(x => x.name == "LearnFromMocapBrain"); _academy = FindObjectOfType <Academy>(); _styleAnimator = FindObjectOfType <StyleTransfer002Animator>(); switch (_brain.brainType) { case BrainType.External: IsInferenceMode = false; break; case BrainType.Player: case BrainType.Internal: case BrainType.Heuristic: IsInferenceMode = true; break; default: throw new System.NotImplementedException(); } }