hi, i’m just trying to learn how to use WheelCollider.motorTorque , and i saw this script somewhere around
public WheelCollider fr;
public WheelCollider fl;
public WheelCollider br;
public WheelCollider bl;
public float speed = 10.0f;
public float steerSpeed = 10.0f;
public GameObject COM;
int gear = 4;
void Start ()
{
rigidbody.centerOfMass = COM.transform.localPosition;
rigidbody.angularDrag = 10;
br.motorTorque = 30;
bl.motorTorque = 30;
}
void Update ()
{
if (Input.GetKeyDown("1"))
{
gear = 1;
}
if (Input.GetKeyDown ("2"))
{
gear = 2;
}
if (Input.GetKeyDown ("3"))
{
gear = 3;
}
if (Input.GetKeyDown("4"))
{
gear = 4;
}
}
void FixedUpdate()
{
fr.steerAngle = Input.GetAxis("Horizontal") * steerSpeed;
fl.steerAngle = Input.GetAxis("Horizontal") * steerSpeed;
br.motorTorque = Input.GetAxis("Vertical") * speed * gear;
bl.motorTorque = Input.GetAxis("Vertical") * speed * gear;
}
so i made a box and some clyinders to make them a car and an empety GameObject to be the COM and centered it to all the wheels to test this script(i didn’t parent any thing)
and i tested it but the wheels doesn’t move, the front wheel’s WheelCollider is rotating well but it never moves, sorry for being so stupid >,< ![]()
You may be better off starting with the Car Tutorial, it's free on the Asset Store.
– WazSorry, but for me at least, it's easier to help people after they have learned something from a book. I'm lazy see. Best of luck.
– Waz