car gearRatio

Hi some one help please i hate i++ stuff cuz i don’t know how to control it
i have problem on line 9
this is flat tutorial script im trying to convert to c and understand it

void  EngineSound (){
		for (int i= 0; i < gearRatio.Length; i++){
			if(gearRatio*> currentSpeed){*
  •  		break;*
    
  •  	}*
    
  •  }*
    
  •  float gearMinValue = 0.00f;*
    
  •  float gearMaxValue = 0.00f;*
    
  •  if (i == 0f){*
    
  •  	gearMinValue = 0f;*
    
  •  }*
    
  •  else {*
    
  •  	gearMinValue = gearRatio[i-1];*
    
  •  }*
    

_ gearMaxValue = gearRatio*;_
_
float enginePitch = ((currentSpeed - gearMinValue)/(gearMaxValue - gearMinValue))+1;_
_
//GetComponent.().pitch = enginePitch;_
_
secEngine.pitch = enginePitch;*_

* }*
here is javaa script version

function EngineSound() {
for (var i = 0; i < gearRatio.length; i++){
if(gearRatio*> currentSpeed){*
break;
}
}
var gearMinValue : float = 0.00;
var gearMaxValue : float = 0.00;
if (i == 0){
gearMinValue = 0;
}
else {
gearMinValue = gearRatio[i-1];
}
gearMaxValue = gearRatio*;*
var enginePitch : float = ((currentSpeed - gearMinValue)/(gearMaxValue - gearMinValue))+1;
GetComponent.().pitch = enginePitch;
SecEngine.GetComponent.().pitch = enginePitch;

}
}

i found it in youtube between comments…Enjoy!

using UnityEngine;
using System.Collections;

public class CarControlScript : MonoBehaviour {

	public Vector3 centerOfMass; //this variable will allow us to change the center of mass in the inspector
	public WheelCollider WheelFL;
	public WheelCollider WheelFR;
	public WheelCollider WheelRL;
	public WheelCollider WheelRR;
	public Transform WheelFLTrans;
	public Transform WheelFRTrans;
	public Transform WheelRLTrans;
	public Transform WheelRRTrans;
	public float lowestSteerAtSpeed = 50f;
	public float lowSpeedSteerAngle = 10f;
	public float highSpeedSteerAngle = 1f;
	public float decelerationSpeed = 30f;
	public float maxTorque = 50f;
	public float topSpeed = 150f;
	public float maxReverseSpeed = 50f;
	public GameObject backLightObject;
	public Material idleLightMaterial;
	public Material brakeLightMaterial;
	public Material reverseLightMaterial;
	public float maxBrakeTorque = 100;
	public int[] gearRatio;
	public int gear;
	
	private float currentSpeed; //private variables are hidden in the inspector
	private bool braked = false;
	private float mySidewaysFriction;
	private float myForwardFriction;
	private float slipSidewaysFriction;
	private float slipForwardFriction;
	
	void Start () {
		Vector3 temp = rigidbody.centerOfMass;
		temp.y = centerOfMass.y; // removed -0.9f; //the f indicates that this is a floating point variable.
		temp.z = centerOfMass.z; //removed 0.5f; please set these values in the inspector
		rigidbody.centerOfMass = temp;
		SetValues ();
	}
	
	void SetValues ()
	{
		myForwardFriction = WheelRR.forwardFriction.stiffness;
		mySidewaysFriction = WheelRR.sidewaysFriction.stiffness;
		slipForwardFriction = 0.05f;
		slipSidewaysFriction = 0.085f;
	}
	
	void FixedUpdate () {
		Control ();
		HandBrake ();
	}
	
	void Update ()
	{
		WheelFLTrans.Rotate(WheelFL.rpm/60*360*Time.deltaTime, 0, 0);
		WheelFRTrans.Rotate(WheelFR.rpm/60*360*Time.deltaTime, 0, 0);
		WheelRLTrans.Rotate(WheelRL.rpm/60*360*Time.deltaTime, 0, 0);
		WheelRRTrans.Rotate(WheelRR.rpm/60*360*Time.deltaTime, 0, 0);
		Vector3 temp = WheelFLTrans.localEulerAngles;
		temp.y = WheelFL.steerAngle - WheelFLTrans.localEulerAngles.z;
		WheelFLTrans.localEulerAngles = temp;
		Vector3 temp2 = WheelFRTrans.localEulerAngles;
		temp2.y = WheelFR.steerAngle - WheelFRTrans.localEulerAngles.z;
		WheelFRTrans.localEulerAngles = temp2;
		BackLight ();
		WheelPosition ();
		ReverseSlip ();
		EngineSound ();
	}
	
	void Control ()
	{
		currentSpeed = 2*Mathf.PI*WheelRL.radius*WheelRL.rpm*60/1000; //replaced 22/7 with Mathf.PI
		currentSpeed = Mathf.Round(currentSpeed);
		if (currentSpeed < topSpeed && currentSpeed > -maxReverseSpeed && !braked)
		{
			WheelRR.motorTorque = maxTorque * Input.GetAxis("Vertical");
			WheelRL.motorTorque = maxTorque * Input.GetAxis("Vertical");
		}
		else
		{
			WheelRR.motorTorque = 0;
			WheelRL.motorTorque = 0;
		}
		if (Input.GetButton("Vertical") == false)
		{
			WheelRR.brakeTorque = decelerationSpeed;
			WheelRL.brakeTorque = decelerationSpeed;
		}
		else
		{
			WheelRR.brakeTorque = 0;
			WheelRL.brakeTorque = 0;
		}
		float speedFactor = rigidbody.velocity.magnitude/lowestSteerAtSpeed;
		float currentSteerAngle = Mathf.Lerp(lowSpeedSteerAngle, highSpeedSteerAngle, speedFactor);
		currentSteerAngle *= Input.GetAxis("Horizontal");
		WheelFL.steerAngle = currentSteerAngle; //removed 10 * Input.GetAxis("Horizontal");
		WheelFR.steerAngle = currentSteerAngle; //removed 10 * Input.GetAxis("Horizontal");
	}
	
	void BackLight ()
	{
		if (currentSpeed > 0 && Input.GetAxis("Vertical") < 0 && !braked)
		{
			backLightObject.renderer.material = brakeLightMaterial;
		}
		else if (currentSpeed < 0 && Input.GetAxis("Vertical") > 0 && !braked)
		{
			backLightObject.renderer.material = brakeLightMaterial;
		}
		else if (currentSpeed < 0 && Input.GetAxis("Vertical") < 0 && !braked)
		{
			backLightObject.renderer.material = reverseLightMaterial;
		}
		else if (!braked)
		{
			backLightObject.renderer.material = idleLightMaterial;
		}
	}
	
	void WheelPosition ()
	{
		RaycastHit hit;
		Vector3 wheelPos;
		if (Physics.Raycast (WheelFL.transform.position, -WheelFL.transform.up, out hit, WheelFL.radius+WheelFL.suspensionDistance))
		{
			wheelPos = hit.point + WheelFL.transform.up * WheelFL.radius;
		}
		else
		{
			wheelPos = WheelFL.transform.position - WheelFL.transform.up * WheelFL.suspensionDistance;
		}
		WheelFLTrans.position = wheelPos;
		
		if (Physics.Raycast (WheelFR.transform.position, -WheelFR.transform.up, out hit, WheelFR.radius+WheelFR.suspensionDistance))
		{
			wheelPos = hit.point + WheelFR.transform.up * WheelFR.radius;
		}
		else
		{
			wheelPos = WheelFR.transform.position - WheelFR.transform.up * WheelFR.suspensionDistance;
		}
		WheelFRTrans.position = wheelPos;
		
		if (Physics.Raycast (WheelRL.transform.position, -WheelRL.transform.up, out hit, WheelRL.radius+WheelRL.suspensionDistance))
		{
			wheelPos = hit.point + WheelRL.transform.up * WheelRL.radius;
		}
		else
		{
			wheelPos = WheelRL.transform.position - WheelRL.transform.up * WheelRL.suspensionDistance;
		}
		WheelRLTrans.position = wheelPos;
		
		if (Physics.Raycast (WheelRR.transform.position, -WheelRR.transform.up, out hit, WheelRR.radius+WheelRR.suspensionDistance))
		{
			wheelPos = hit.point + WheelRR.transform.up * WheelRR.radius;
		}
		else
		{
			wheelPos = WheelRR.transform.position - WheelRR.transform.up * WheelRR.suspensionDistance;
		}
		WheelRRTrans.position = wheelPos;
	}
	
	void HandBrake ()
	{
		if (Input.GetButton("Jump"))
		{
			braked = true;
		}
		else
		{
			braked = false;
		}
		if (braked)
		{
			if (currentSpeed > 1)
			{
				WheelFR.brakeTorque = maxBrakeTorque;
				WheelFL.brakeTorque = maxBrakeTorque;
				WheelRR.motorTorque = 0;
				WheelRL.motorTorque = 0;
				SetRearSlip(slipForwardFriction, slipSidewaysFriction);
			}
			else if (currentSpeed < 0)
			{
				WheelRR.brakeTorque = maxBrakeTorque;
				WheelRL.brakeTorque = maxBrakeTorque;
				WheelRR.motorTorque = 0;
				WheelRL.motorTorque = 0;
				SetRearSlip(1, 1);
			}
			else
			{
				SetRearSlip(1, 1);
			}
			if (currentSpeed < 1 && currentSpeed > -1)
			{
				backLightObject.renderer.material = idleLightMaterial;
			}
			else
			{
				backLightObject.renderer.material = brakeLightMaterial;
			}
		}
		else
		{
			WheelFR.brakeTorque = 0;
			WheelFL.brakeTorque = 0;
			SetRearSlip(myForwardFriction, mySidewaysFriction);
		}
	}
	
	void ReverseSlip ()
	{
		if (currentSpeed < 0)
		{
			SetFrontSlip(slipForwardFriction, slipSidewaysFriction);
		}
		else
		{
			SetFrontSlip(myForwardFriction, mySidewaysFriction);
		}
	}
	
	void SetRearSlip (float currentForwardFriction, float currentSidewaysFriction)
	{
		//set forward friction for the rear wheels
		WheelFrictionCurve tempWheelRR = WheelRR.forwardFriction;
		tempWheelRR.stiffness = currentForwardFriction;
		WheelRR.forwardFriction = tempWheelRR;
		WheelFrictionCurve tempWheelRL = WheelRL.forwardFriction;
		tempWheelRL.stiffness = currentForwardFriction;
		WheelRL.forwardFriction = tempWheelRL;
		
		//set sideways friction for the rear wheels
		WheelFrictionCurve tempWheelRR2 = WheelRR.sidewaysFriction;
		tempWheelRR2.stiffness = currentSidewaysFriction;
		WheelRR.sidewaysFriction = tempWheelRR2;
		WheelFrictionCurve tempWheelRL2 = WheelRL.sidewaysFriction;
		tempWheelRL2.stiffness = currentSidewaysFriction;
		WheelRL.sidewaysFriction = tempWheelRL2;
	}
	
	
	void SetFrontSlip (float currentForwardFriction, float currentSidewaysFriction)
	{
		//set forward friction for the front wheels
		WheelFrictionCurve tempWheelFR = WheelFR.forwardFriction;
		tempWheelFR.stiffness = currentForwardFriction;
		WheelFR.forwardFriction = tempWheelFR;
		WheelFrictionCurve tempWheelFL = WheelFL.forwardFriction;
		tempWheelFL.stiffness = currentForwardFriction;
		WheelFL.forwardFriction = tempWheelFL;
		
		//set sideways friction for the front wheels
		WheelFrictionCurve tempWheelFR2 = WheelFR.sidewaysFriction;
		tempWheelFR2.stiffness = currentSidewaysFriction;
		WheelFR.sidewaysFriction = tempWheelFR2;
		WheelFrictionCurve tempWheelFL2 = WheelFL.sidewaysFriction;
		tempWheelFL2.stiffness = currentSidewaysFriction;
		WheelFL.sidewaysFriction = tempWheelFL2;
	}
	
	void EngineSound ()
	{
		for (int i = 0; i < gearRatio.Length; i++)
		{
			if (gearRatio *> currentSpeed)*
  •  	{*
    
  •  		gear = i;*
    
  •  		break;*
    
  •  	}*
    
  •  }*
    
  •  float gearMinValue = 0.00f;*
    
  •  float gearMaxValue = 0.00f;*
    
  •  if (gear == 0)*
    
  •  {*
    
  •  	gearMinValue = 0f;*
    
  •  }*
    
  •  else*
    
  •  {*
    
  •  	gearMinValue = gearRatio[gear-1];*
    
  •  }*
    
  •  gearMaxValue = gearRatio[gear];*
    
  •  float enginePitch = ((currentSpeed - gearMinValue) / (gearMaxValue - gearMinValue)) + 1;*
    
  •  audio.pitch = enginePitch; //was currentSpeed / topSpeed + 1;*
    
  • }*
    }