Hi,
I’m having problems. I’m making a car game and since the beginning was using transform.Translate to move it. The problem was that when the car hit another collider, it attempted to go inside it resulting is awful glitches.
Then I tried out moving with velocity. I haven’t tested enough yet, but then moved onto addforce. Addforce caused my car to slip all the time. When I was driving foreward vast and then turned, the car would keep on going and crash.
Now I moved onto using wheelcolliders. I’m moving my car using this script:
using UnityEngine;
using System.Collections;
public class LMovement : MonoBehaviour {
[SerializeField]
WheelCollider FL;
[SerializeField]
WheelCollider FR;
[SerializeField]
WheelCollider RL;
[SerializeField]
WheelCollider RR;
[SerializeField]
float _maxTorque = 50;
[SerializeField]
float _steerAngle = 5;
void Start(){
rigidbody.centerOfMass = transform.up * -0;
}
void FixedUpdate(){
RR.motorTorque = _maxTorque * Input.GetAxis ("Vertical");
RL.motorTorque = _maxTorque * Input.GetAxis ("Vertical");
FR.steerAngle = _steerAngle * Input.GetAxis ("Horizontal");
FL.steerAngle = _steerAngle * Input.GetAxis ("Horizontal");
}
void Update(){
// Yet to come
}
}
It is very basic for now and very realistic. At first I liked the idea, but now I noticed that my car begins to slip to the right while driving forward. Somebooooooooody please help!
Here are my wheels’ settings:
All of them are the same (size, height, settings, etc). My surface is flat. If that’s the reason then please give me some tips.