how to setup wheeljoint2D motor by code?

Hello all!

i’m trying to setup simple 2d car physics.
i have a car with two WheelJoint2D component. each one of them hold one wheel.
every thing is working fine beside the fact that i can’t setup the motor by code (C#)
here my simple script that should set the motor to -1000 and make the car jump with space key. (ignore that fact that it will jump once)

using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour {

	private bool isGrounded= true;

	public float Power;
	public float speed;
	public WheelJoint2D wheelj1; // draged to this one the front wheel WheelJoint2D
	public WheelJoint2D wheelj2; // draged to this one the back wheel WheelJoint2D

	public JointMotor2D wheelj1jm;
	public JointMotor2D wheelj2jm;


	// Use this for initialization
	void Start () {
		speed = -1000f;
		wheelj1jm = wheelj1.motor;
		wheelj2jm = wheelj2.motor;

		wheelj1.useMotor=true;
		wheelj1jm.motorSpeed = speed; // try to setup the motor speed - nothing happen!
	
	}
	
	// Update is called once per frame
	void FixedUpdate () {


		if(Input.GetKey(KeyCode.Space) && isGrounded ){
			this.rigidbody2D.AddForce(transform.up * Power);
			isGrounded=false;
		}
	
	}
}

i tried to find some sample code for this but couldn’t find any. i don’t get any error but the motor don’t get i value -1000. what am i doing wrong?
thanks!

Have you tried adding “wheelj1.motor = wheelj1jm;” after setting “wheelj1jm.motorSpeed = speed;” ?