I cannot seem to set the motor speed of a motor with this script. I can set it manually from within unity, but it does not work from the script. Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Paddle : MonoBehaviour {
private Rigidbody2D rb2d;
private JointMotor2D motor;
public float speed = 100;
// Use this for initialization
void Start () {
rb2d = GetComponent<Rigidbody2D> ();
motor = GetComponent<JointMotor2D> ();
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown ("left"))
motor.motorSpeed = speed;
}
void FixedUpdate ()
{
}
}