Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Visual wheels rotating around wrong axes (WheelCollider Tutorial).

Discussion in 'Editor & General Support' started by u_rs, May 23, 2017.

  1. u_rs

    u_rs

    Joined:
    Jan 5, 2016
    Posts:
    147
    Following WheelCollider Tutorial tutorial I've got wheels flipping like coins.
    How it looks in the editor:


    This is how it looks in a game:

    (why position values always changing while car is not moving ?)

    Position of front left empty object (front left wheel):


    Position of cylinder for front left wheel:


    I tried to change rotation field for visual wheels but game mode always sets Z Rotation to 0.
    During drive, rotation of visual wheel happening around X axis.
     

    Attached Files:

    Last edited: May 24, 2017
    40detectives likes this.
  2. u_rs

    u_rs

    Joined:
    Jan 5, 2016
    Posts:
    147
    I created cylinder in Blender so that X axis comes though wheel's axis (through flat side). But now there is another problem - wobbling wheels.
     
    Last edited: May 25, 2017
  3. 40detectives

    40detectives

    Joined:
    Apr 9, 2016
    Posts:
    74
    I got the same problem.

    What I did was to put the visual wheels object (which were just built-in unity's cylinders) on a empty parent, and rotate my wheel meshes inside the wrapper parent, but leave the parent with the transform reset.

    Then I removed the colliders in the cylinders object, because of this the car didn't move. After all we already have a WheelsColliders in the grandparent of the visual wheel gameobject.

    To stop the wobbling effect in the wheels I first fixed X-Axis rotation on the rigidbody of the car root element.

    Then I found this, where a user recommends to change the damper of the WheelCollider to the same as the mass for a 4 wheel car.
    This also seems to fix the wobbling effect.


    I think that tutorial needs some editing, but well, this is as far I could get. If anyone has more idea on car controlling and can shed some light here, I'd be really grateful.
     
    Last edited: Jun 29, 2017
  4. EliasMc

    EliasMc

    Joined:
    Oct 7, 2012
    Posts:
    1
    For me what I did, was take the rot return of the wheel collider and add 90 degrees to the y axis like this:

    Code (CSharp):
    1. void UpdateWheelPos(WheelCollider col, Transform t)
    2.     {
    3.         Vector3 pos = t.position;
    4.         Quaternion rot = t.rotation;
    5.         col.GetWorldPose(out pos, out rot);
    6.         rot = rot * Quaternion.Euler(new Vector3(0, 90, 0));
    7.         print(rot);
    8.         t.position = pos;
    9.         t.rotation = rot;
    10.     }
    before.PNG

    after.PNG

    Before and after
     
  5. Taku-chan-gamer

    Taku-chan-gamer

    Joined:
    Nov 18, 2019
    Posts:
    35
    my problem is that the steering wheel flips like a coin
     
  6. djakap

    djakap

    Joined:
    Oct 18, 2020
    Posts:
    2
    multiply the rot, like this = rot * Quaternion.Euler(0, 0, 90).
    it fixed mine
     
  7. superraptor31

    superraptor31

    Joined:
    Dec 15, 2021
    Posts:
    2
    my problem is the left front and rear wheel are flipped how do u fix that?