// Update is called once per frame void Update() { if (!selfDrive) { UpdateFitness(); if (CheckFailure()) { return; } } if (genome == null) { return; } if (selfDrive || !hasFailed) { genome.net.SetInput(raycast.GetProbes()); genome.net.refresh(); leftForce = genome.net.GetOutput(0); rightForce = genome.net.GetOutput(1); leftTheta = MAX_ROTATION * leftForce; rightTheta = MAX_ROTATION * rightForce; headingAngle += (leftTheta - rightTheta) * Time.fixedDeltaTime; float speed = (Mathf.Abs(leftForce + rightForce)) / 2; speed *= _SPEED; speed = Clamp(speed, -_SPEED, _SPEED); } }