- Home /
 
               Question by 
               ameenulislam4 · Oct 03, 2019 at 08:21 AM · 
                unity 2dbuttonstouch controls  
              
 
              How to use touch buttons to move a Wheeljoint 2D?
Hey there , I have been building a balance car game(Like hill climb racing). I wanna build it for android. I want the vehicle to move when buttons are clicked. I have no idea how that is done.I am attaching the link for the "PC" version of the game for a better understanding.` public float speed = 1500;
 public WheelJoint2D frontWheel;
 public WheelJoint2D backWheel;
 public Rigidbody2D player;
   
 float movement = 0;
 void Update()
 {
     
 }
 public void FixedUpdate()
 {
     movement = Input.GetAxisRaw("Horizontal") * speed;
     if (movement == 0)
     {
         frontWheel.useMotor = false;
         backWheel.useMotor = false;
     }
     else
     {
         frontWheel.useMotor = true;
         backWheel.useMotor = false;
         JointMotor2D motor = new JointMotor2D { motorSpeed = movement, maxMotorTorque = 10000 };
         frontWheel.motor = motor;
         backWheel.motor = motor;
     }
     
 }
} `
]
Game link: [1]: https://ameenulislam.itch.io/johns-dream-ride?secret=fuquKlsDg54z0bEhsJPxnQJofpg
Thanks In advance, Ameen.
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Make touch buttons transparent 2 Answers
Referencing variables from a UI elements script on another gameobject? 1 Answer
Grabbing objects for touch controls? how 2 Answers
Rotate gameObject with touch controls OR gameObject follow finger 1 Answer
override touch control when pressing a button (android) 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                