Here is my code so far
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Paddle : MonoBehaviour {
private Rigidbody2D rb2d;
private HingeJoint2D jointRef;
private JointMotor2D motorRef;
public float speed = -100;
// Use this for initialization
void Start () {
rb2d = GetComponent<Rigidbody2D> ();
jointRef = GetComponent<HingeJoint2D> ();
motorRef = jointRef.motor;
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown ("left"))
motorRef.motorSpeed = speed;
}
void FixedUpdate ()
{
}
}