Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Adding Mass to Car Parts

Discussion in 'Physics' started by CreeperSaviour, Jul 20, 2023.

  1. CreeperSaviour

    CreeperSaviour

    Joined:
    Apr 16, 2023
    Posts:
    17
    Hello. Last time I asked a question in this forum to create a car. (this)



    This time I wanted to add mass to each component (body, fronLeft, frontRight, backLeft, backRight), so I added RigidBody. The result is as follows



    We added a Fixed Joint to each Wheel because we thought that adding a RigidBody to a child of a component that is in a parent-child relationship would break the tracking relationship.



    However, this did not work either and I have no way to do anything about it.
    I would appreciate any wisdom you can share. Thank you.
     
  2. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    Follow the WheelCollider tutorial to create a car with wheels and steering. Once you have that, add other stuff.
     
  3. CreeperSaviour

    CreeperSaviour

    Joined:
    Apr 16, 2023
    Posts:
    17
    Yes. I created this car by following the tutorial on WheelCollider: https://docs.unity3d.com/ja/current/Manual/WheelColliderTutorial.html

    So I made a hierarchical structure like in the picture and it worked.

    However, I ran into a problem with the body shaking. I think it might be a collider related problem, but I am not sure. .... Sorry .....

     
  4. CreeperSaviour

    CreeperSaviour

    Joined:
    Apr 16, 2023
    Posts:
    17
    picture
     

    Attached Files:

  5. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    If it drives, then it should be mostly right. Start debugging then. For colliders, check that the wheelcollider parameters are the same. Check that all transform scales=1
     
  6. CreeperSaviour

    CreeperSaviour

    Joined:
    Apr 16, 2023
    Posts:
    17
    WheelCollider parameters are consistent for all tires.
    Most of the Transforms have a Scale of 1, but only the body has Z=3. Is this bad?
     
  7. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    Shouldn't be. I'm out of straight off ideas though. You'll find it.
     
  8. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,423
    Try reducing the height of the center of mass. If you haven't configured the center of mass explicitly in the rigidbody (Rigidbody.centerOfMass) then it defaults to the center of the cube, which is too high for a standard car.

    Also, I recommend you to use 3D models of cars from the beginning, even really simple ones, as long as they have realistic dimensions. That gives you a ton of visual feedback for configuring the physics elements, as well as how the simulation is performing during development. Using boxes and cylinders typically produces boxes and cylinders physics, not necessarily car physics.
     
    Last edited: Jul 25, 2023
  9. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,423
    Yes, it is bad! If "body" has some scale different than 1 it means that all its children are also scaled!

    In this case this is not necessarily the cause of the issue, but you should have in mind that scale is inherited. As a general rule ensure that all physics elements (Rigidbody, WheelCollider, joints) have scale = 1 on their Transform and all of their ancestors. You may scale only the visual elements (cube, cylinder) and their corresponding colliders.
     
  10. CreeperSaviour

    CreeperSaviour

    Joined:
    Apr 16, 2023
    Posts:
    17
    Da
    Thank you. Actually, it looks like it worked when I put the center of gravity down.
    upload_2023-7-25_13-30-20.png

    I also reviewed the hierarchy in addition to this. (I did not use Cube for body, but added visualBody below it).

    upload_2023-7-25_13-30-36.png

    At the same time, we set the body's scale z to 1 and the visualBody's z to 3.

    > Also, I recommend you to use 3D models of cars from the beginning, even really simple ones, as long as they have realistic dimensions.
    Thank you for pointing this out. However, I am trying to create a construction machine, not a car, as my ultimate goal. For example backHoe. we have 3DCad data, but I am in the form of trying to find a way to convert it into a Unity model. Thanks.
     
    Edy likes this.