C# Crouch script problem

I’m trying to get my First Person Controller to “crouch” with this script, and I am getting some big errors. Apparently Player.transform.position.y and Player.transform.localScale.y are not variables that I can set. Does anybody know the proper syntax of what I am trying to access and alter? Here is the code:


1    public void Update()
2        {
3            if(Input.GetButtonDown("Crouch"))
4            {
5                Player.transform.position.y -= .5;
6                Player.transform.localScale.y -= .5;
7                Crouch = true;
8            }
9        }

If you take a look at the scripting docs, you’ll see that there are a number of instances where you can’t directly alter values in C#. Instead, you have to create a temporary variable, usually just in the assignment, that will be used to modify the current value. It’s strange (to me) and I’m not exactly sure what the rule is, but it’s there.

Instead of

Player.transform.localScale.y -= .5;

try

Player.transform.localScale -= new Vector3(0,.5F,0);