//Updates nerual net with new inputs from the balancer private void UpdateNet() { float boardVelocity = trackRigidbody.velocity.x; //get current velocity of the board //both poles angles in radians float pole1AngleRadian = Mathf.Deg2Rad * pole1Rigidbody.transform.eulerAngles.z; float pole2AngleRadian = Mathf.Deg2Rad * pole2Rigidbody.transform.eulerAngles.z; //both poles angular velocities float pole1AngularVelocity = pole1Rigidbody.angularVelocity; float pole2AngularVelocity = pole2Rigidbody.angularVelocity; float[] inputValues = { boardVelocity, pole1AngleRadian, pole2AngleRadian, pole1AngularVelocity, pole2AngularVelocity }; //gather pole and track data into an array float[] output = net.FireNet(inputValues); //caluclate new neural net output with given input values trackRigidbody.velocity += new Vector2(output[0], 0); //update track velocity with neural net output net.AddNetFitness(Time.deltaTime); }