Ok, this one has been discussed many times both around here and on UnityAnswers. I already know it’s all matter of static/dynamic typing, but… Despite all the answers I read around, I still can’t figure out how to retype my code to clear this error.
I’m on Unity 3.2, writing a very simple JavaScript to get a car driving around on iPhone 4. On PC with UnityRemote, it works perfectly.
Here it is what I have:
#pragma strict
var steering = 20;
function FixedUpdate () {
//Steer the car
collider.steerAngle = -(Input.acceleration.y*steering);
}
When compiling, this is the well-known error: BCE0019: ‘steerAngle’ is not a member of ‘UnityEngine.Collider’
This script is attached to both the front wheels of the car.
Rear wheels have a very similar script that manages torque/brake instead of steering, and obviously it gives the same error (but with motorTorque and brakeTorque instead of steerAngle).
So… Could you help me to fix it, please? 
collider is of type Collider, not WheelCollider.
You will have to cast it to WheelCollider first so
#pragma strict
var steering = 20;
function FixedUpdate () {
//Steer the car
var wheel = collider as WheelCollider;
wheel.steerAngle = -(Input.acceleration.y*steering);
}
for example
This is working perfectly, thank you so much! 
So, let’s see if I understood this static code thing…
I have first to specify that my collider is not a standard collider, but a WheelCollider, otherwise Unity won’t find its specific functions. I can do this by handling the collider like a variable, as you wrote:
var wheel = collider as WheelCollider;
Then, everytime I need to read infos from it, I just use the name of the variable (wheel in this case) instead of collider.
Am I right?
Right
The line you quoted there is a type cast from the more general Collider to the specialized WheelCollider
You could do it right in the line where you want the wheel collider but as you might want to change more than one entry, caching it is a good idea. You could actually do it already in start and store wheel on the class itself, then you don’t have to refetch it again.
Perfect, thank you very much for your precious help. 