Video showcase:
Hey, I’ve been working on my Bachelor’s project (due next month - hence the urgency) in Unity that requires training a car using ML Agents, and lately I wanted to improve my car’s movement by making use of Wheel Colliders to make the car turning more realistic.
I worked on this project on my computer and there is just the basic code for making the wheels move, however no matter what I changed, upon moving the car it would start spinning uncontrollably.
When I cloned this project (all Assets and Scenes included) to my dad’s computer, we made no changes to the project and on his device, after hitting the Play button, the car moved perfectly. Everything is written in a FixedUpdate() and I tried capping the FPS and playing around with vSync in case that was the issue. Restarted computer, tried different Unity versions, no avail.
I’ll be happy to share more information when needed, but I have no clue where to even start looking at this point. The only code running on the car:
public class CarControllerWheels : MonoBehaviour
{
[SerializeField] WheelCollider frontRight;
[SerializeField] WheelCollider frontLeft;
[SerializeField] WheelCollider backRight;
[SerializeField] WheelCollider backLeft;
public float acceleration = 500f;
public float breakingForce = 300f;
public float maxTurnAngle = 15f;
public float currentAcceleration = 0;
public float currentBreakForce = 0;
public float currentTurnAngle = 0;
private Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
rb.ResetInertiaTensor(); //attempted fix by resetting the tensor, made no changes
}
// Update is called once per frame
void FixedUpdate()
{
currentAcceleration = acceleration * Input.GetAxis("Vertical");
if (Input.GetKey(KeyCode.Space))
{
currentBreakForce = breakingForce;
}
else
{
currentBreakForce = 0f;
}
frontRight.motorTorque = currentAcceleration;
frontLeft.motorTorque = currentAcceleration;
frontRight.brakeTorque = currentBreakForce;
frontLeft.brakeTorque = currentBreakForce;
backRight.brakeTorque = currentBreakForce;
backLeft.brakeTorque = currentBreakForce;
currentTurnAngle = maxTurnAngle * Input.GetAxis("Horizontal");
frontLeft.steerAngle = currentTurnAngle;
frontRight.steerAngle = currentTurnAngle;
}
Hello @LuLa90, When you pushed the project did you ignore some files with git ignore? did you check if you had exactly the same settings on both computers? Could you try to remove the project settings file in order for unity to reset it and try again please? Also maybe it's a hardware problem, is your computer slow or low in performances? Unity can sometimes use external libraries and if something is corrupted on your computer it might affect your project, have you tried making an executable (one on each computer and try both on both computer) to see if the behaviour is the same?
– Cyber_Cats