hello everyone, I’m making a car and a wheel, the problem is when the car rotates (I gave an example when the car falls and spins) then the wheel follows the position of the car, but also rotates following the car, for example the car rotates to the right, then the wheel also rotates to the right, is there how to lock the car wheels so they can’t rotate freely?
sorry for the photo,
for a while I’ve been looking for it on the internet, it didn’t work,
oh yes, here is the code and i just added that script to object car
float wheel;
public GameObject w1, w2, w3, w4;
Rigidbody rg;
void Start()
{
rg = GetComponent<Rigidbody>();
}
void Update()
{
wheel += rg.velocity.z;
w1.transform.rotation = Quaternion.Euler(wheel, 0, 0);
w2.transform.rotation = Quaternion.Euler(wheel, 0, 0);
w3.transform.rotation = Quaternion.Euler(wheel, 0, 0);
w4.transform.rotation = Quaternion.Euler(wheel, 0, 0);
if (Input.GetKey(KeyCode.DownArrow))
{
rg.AddForce(Vector3.back * 1, ForceMode.VelocityChange);
}
