public AiInfo(GameObject _initialObj, AiPid _pid, AiSettings _setings, float _cumulativeError) { initialObj = _initialObj; pid = _pid; setings = _setings; cumulativeError = _cumulativeError; }
void Start() { foreach (var item in gameObject.GetComponentsInChildren <WheelCollider>()) { // This forloop shouln'd exit but unity wouln'd link the correct wheels. if (item.name == "FrontWheel") { frontWheel = item; } else if (item.name == "BackWheel") { backWheel = item; } } MovementStart(); pid = GetComponent <AiPid>(); pid.UpdateErrorValue += () => { pid.errorVariable = (aiSettings.targetSqrSpeed - velocitySqr) / aiSettings.targetSqrSpeed; float accel = (velocitySqr - lastVelocitySqr) / Time.deltaTime; float val = (aiSettings.targetMaximumAcceleration - accel) / aiSettings.targetMaximumAcceleration * pid.errorVariable; pid.errorVariable += val; }; aiSettings.SetRandomValues(); timeAlive = 0; InitialiseRespawn(); respawn.CallRespawnAction(); }
void Start() { nearestNode = 0; pid = GetComponent <AiPid>(); aiSettings.SetRandomValues(); GetComponent <Respawn>().onRespawn += aiSettings.SetRandomValues; GetComponent <Respawn>().onRespawn += pid.ResetValues; GetComponent <Respawn>().onRespawn += () => { StartCoroutine(RestartHelper()); }; backWheel.ConfigureVehicleSubsteps(1, 12, 15); frontWheel.ConfigureVehicleSubsteps(1, 12, 15); rigidbody = GetComponent <Rigidbody>(); frontWheel.brakeTorque = 0; backWheel.brakeTorque = 0; SetUpPIDReferences(); }