wheel rotation follows the car

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?183562-up.png


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);
        }

well for once you probably do not want to use the Euler angles function here but in general you have to set the local rotation of the transform.
Otherwise you will set the rotation in respect to absolute global frame of reference.

wX.transform.localRotation = ...