Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Wheels rotate around themselves

Discussion in 'Editor & General Support' started by Veteranfighter, Mar 17, 2021.

  1. Veteranfighter

    Veteranfighter

    Joined:
    Jul 3, 2020
    Posts:
    15
    upload_2021-3-17_14-25-44.png

    Hello, I'm currently trying to create a racing game. I tried adding the first car, but it didn't really work.
    The wheels start spinning around themselves as soon as I drive.

    Also it looks like the offsets are wrong:

    upload_2021-3-17_14-27-45.png

    I'm using the WheelCollider and my custom script to move the car. (I already tried it with another car consisting of one cube and 4 cylinders and it worked perfect). upload_2021-3-17_14-25-44.png
     

    Attached Files:

  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
    Looks like the center of your wheel object is not at its axis of rotation.

    Either fix the geometry for the wheel in a 3D editor program (the BEST solution), or else reparent the wheel under another GameObject and add an offset so that when you spin the parent object the wheel rotates correctly.

    NOTE: with 3D objects on import sometimes their transforms are not identity scaling (1,1,1) or rotating (0,0,0). For instance, Blender3D objects by default import with (-90,0,0) rotating, which can be confusing when you're trying to spin things properly.
     
  3. Veteranfighter

    Veteranfighter

    Joined:
    Jul 3, 2020
    Posts:
    15
    Hello, thanks for your reply. The weird thing is it looks totally normal in the editor: upload_2021-3-17_19-46-47.png
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
    That's not weird. The pivot point could be on the moon and it would still look normal if it was offset properly.

    Think of it this way: I give you a bicycle and I say "Put this bicycle on this painted spot on the ground."

    What part of the bicycle goes on that spot? Just sort of in the middle? The handlebars? The front wheel? The back wheel? The seat?

    That's the pivot point.
     
  5. Veteranfighter

    Veteranfighter

    Joined:
    Jul 3, 2020
    Posts:
    15
    All clear. Thank you, I understand that so far. One more thing, do you have a resource that explains well the process of rearranging the wheels?
     
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
    It's just parenting one game object to another if you do it in Unity.

    If you do it in your favorite 3D program, well, that's very specific steps for each one.
     
    Veteranfighter likes this.
  7. Veteranfighter

    Veteranfighter

    Joined:
    Jul 3, 2020
    Posts:
    15
    Yeah, but as soon as I set the parent it starts spinning around that object
     
  8. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,520
    You need to adjust the position of the wheel relative to the parent until the parent is located in the axial center of the wheel.
     
    Veteranfighter likes this.
  9. Veteranfighter

    Veteranfighter

    Joined:
    Jul 3, 2020
    Posts:
    15
    got it, thank you.
     
    Kurt-Dekker likes this.