You need to modify the entire velocity variable. x, y and z are read-only.
Nonetheless it is not recommended to modify the velocity variable. You should use Physics stuff instead, like AddForce().
http://docs.unity3d.com/ScriptReference/Rigidbody-velocity.html
rigidbody.velocity = new Vector3(rigidbody.velocity.x, speed, rigidbody.velocity.z);
↧