- Home /
 
 
               Question by 
               IanMancuso · Jul 21, 2017 at 01:18 PM · 
                physics2d-physicshingejoint2dmotorpinball  
              
 
              How to make pinball flipper
I am trying to make a pinball game but am having difficulty with the flippers. I have tried to attach motors to the flippers and then used a script to change the motor speed, but so far, they only move when I change the speed in the inspector, not from the script.
This 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 ()
     {
         
         
     }
 }
 
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Cannot change 2d motor speed from script 3 Answers
Cannot set motor speed in script 1 Answer
Why is there no Rigidbody2D.SweepTest() ? 1 Answer
How can i make a ragdoll stickman controller? 0 Answers
Why doesn't the OnTriggerStay2D run? 2 Answers