Unity 5.0, ambiguous component reference?

Unity 5.0 onward, all the component variables except “gameObject”, “transform” and “tag” have been deprecated (See script reference “UnityEngine.Component”), which is alright.

So when one has to access a component,e.g. Rigidbody, as advised, they must use the method GetComponent.Rigidbody(). (Apparently the angle brackets can’t be shown here on the web.)

Instead of using this method every time, one could cache a variable, assign it in the Start() method using GetComponent() and then use that variable to reference the component each time, which is also fine.

If Component.rigidbody has been deprecated, why does Unity send an ambiguous component reference error when I assign the variable as “rigidbody”?

This is the message I get:
Ambiguous reference ‘rigidbody’ : CharacterControl.rigidbody, UnityEngine.Component.rigidbody.
(Here, CharacterControl is my class.)
Well, if there is no variable “rigidbody” in the Component class, why does it send this error?

Yes, I could assign a different name like “myRigidBody” or simply “r” for the variable. But I’d like to know what is happening here. Is it a compiler issue? Is it because MonoDevelop hasn’t been updated?

A method or variable being deprecated is like telling the programmers that they should stop using a variable or method because it will not be available in the future. However it is still available so programs will still work while the programmers transition to the new version. This is why using a deprecated variable gives a warning and not an error and why attempting to declare a new variable with the same name as the deprecated variable is ambiguous. I mean the compiler has no idea whether you are talking about the still implemented (but deprecated) variable or your declared variable.