Hi guys,
I’m working on a 2d game. I connected a dirt bike to its wheels by a hinge joint, but i can’t change the motor speed of the hinge joint motor.
Can you help me?
Tips are welcome!
Thank you
Hi guys,
I’m working on a 2d game. I connected a dirt bike to its wheels by a hinge joint, but i can’t change the motor speed of the hinge joint motor.
Can you help me?
Tips are welcome!
Thank you
You have to manually assign a motor object to the hinge motor.
using UnityEngine;
using System.Collections;
public class HingeMotor : MonoBehaviour {
// Use this for initialization
void Start () {
HingeJoint2D hinge = GetComponent<HingeJoint2D>();
JointMotor2D motor = hinge.motor;
motor.motorSpeed = 100f;
hinge.motor = motor;
}
// Update is called once per frame
void Update () {
}
}
Thank you for your help. Your code works great!