Hi
Im having problems with the wheel coliders I have created for the tires I have. I have wheel colliders on all four tires and have a script that allows me to move the car but when I press play the front wheels turn right and the car goes backwards and flips over
I am stumped as to why this is doing it cause all the wheels are set to 0 on the z axis same with all the wheel coliders. plus I have also tried sizing them up and down to see if that makes any difference.
This is the code that I have that makes the car move
using System.Collections;
using UnityEngine;
public class Car : MonoBehaviour
{
public float maxTorque = 50f;
public WheelCollider[] wheelColliders = new WheelCollider[4];
public Transform[] tireMeshes = new Transform[4];
void Update()
{
UpdateMeshesPositions();
}
void FixedUpdate()
{
float steer = Input.GetAxis ("Horizontal");
float accelrate = Input.GetAxis ("Vertical");
float finalAngle = steer * 45f;
wheelColliders [0].steerAngle = finalAngle;
wheelColliders [1].steerAngle = finalAngle;
for (int i = 0; i < 4; i++)
{
wheelColliders[i].motorTorque = accelrate * maxTorque;
}
}
void UpdateMeshesPositions()
{
for(int i = 0; i < 4; i++)
{
Quaternion quat;
Vector3 pos;
wheelColliders[i].GetWorldPose(out pos, out quat);
tireMeshes[i].position = pos;
tireMeshes[i].rotation = quat;
}
}
}
This is what the inpector shows as you can see I only have a rigidbody on the main kart
Wheel Collider
Wheel Mesh
Go Kart
Here is the project file if anyone wants to have a look
http://ge.tt/73YNbdl2