Modify wheelJoint2D motor speed with script

I have a wheelJoint2D component attached to an object and I want to be able to control the motor speed with a script. I tried to access the component using gameObject.GetComponent(WheelJoint2D) which is ok but I can’t seem to be able to access motor speed. I’ve tried variants of the following gameObject.GetComponent(WheelJoint2D).jointSpeed = speed; but I am not able to access the variable.

I’m sure that I’ve misunderstood something basic, I just don’t know what.

In C# you have to do this:

JointMotor2D m = RearWheel.motor;
m.motorSpeed = speed;
RearWheel.motor = m;

Where RealWheel in the above example is the WheelCollider2D object.

It’s like working with transform.position, where you have to use a temp Vector3 vs setting the properties.

‘jointSpeed’ appears to be read-only. Maybe you want motorSpeed?

 gameObject.GetComponent(WheelJoint2D).motor.motorSpeed = 3.0;