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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Question Simple vehicle always wanting to tilt up?

Discussion in 'Physics' started by dylanpdx, Jul 21, 2020.

  1. dylanpdx

    dylanpdx

    Joined:
    Nov 6, 2015
    Posts:
    5
    Hey, i've been having a strange issue with a project i'm working on.

    I have a simple vehicle (4 wheels, joints with motors to rotate them, no suspension)
    Whenever I accelerate, the main body starts to tilt up as if something is rotating it, even though only the wheels are rotating.



    All bodies have a weight of 0.01, and tweaking them doesn't make any difference (i.e making wheels lighter, making main body heavier). Center of mass seems fine, and lowering it also doesn't make a difference. The only thing I haven't played around with is the inertiaTensor.


    Something to note is that i'm using the new PhysX 4 ArticulationBody component introduced in Unity 2020.1, but the same issue occurred using regular RigidBodies. I switched to ArticulationBodies for more joint stability.

    Any ideas on how to fix this issue? Since this is a "build your own creation" type game (i.e Besiege), I want the solution to be applicable even if the object connected to the joint isn't a wheel (it could be an arbitrary body with different mass/shape/etc)

    A side note to this is that after trying this concept with RigidBodies/hinge joints and having them be very unstable/bendy, I wonder how games like the one I mentioned before pull off such "solid" joints. I did also look into testing/buying APE, but it seems they aren't currently selling to indie developers :/ so right now i'm using PhysX 4 as a solution

    Thanks in advance
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,428
    Motors in the wheels apply a counter-torque to the main body, that's why it tilts. I'd ensure the main body is one or two orders of magnitude heavier than the wheels. For example, wheel mass = 1 kg and main body mass = 100 Kg. However, this may have secondary effects in the joint stability itself (as it tends to be more springy when the connected masses are very different).
     
  3. dylanpdx

    dylanpdx

    Joined:
    Nov 6, 2015
    Posts:
    5
    Hmm, while that fixes the issue, that means that the heavier "main body" now moves slower, but I was looking for faster-ish movement. When I increase the speed of the wheels though, the issue happens again (probably because more counter-torque is being applied)

    Is there any way to mitigate/disable this counter-torque? I assume just doing
    body.parent.AddTorque(-body.AngularVelocity)
    won't work

    I'm not entirely concerned with realism for this, I mostly just want it to stay on the ground but go fast as well.