Search Unity

How to fix train chassis bouncing.

Discussion in 'Physics' started by LegalHax, Sep 16, 2017.

  1. LegalHax

    LegalHax

    Joined:
    Sep 16, 2017
    Posts:
    2
    Hello,
    Im sorry for my english. it is very bad.
    I have one train chassis with normal wheel collider and box collider (i taught it from many car tutorials). When i put it on flat ground, it moving nice and smooth without jumping or anything else.

    The problem is when the chassis is on the track with mesh collider (non-convex). When the speed of chassis increasing, chassis start jumping and lagging. After some time it will bounce off the track. All wheel models have convex mesh collider.

    Video

    There is a picture of the track:
    Snímek obrazovky (1).jpg
    Track mesh:
    Snímek obrazovky (2).jpg
    Track Collider:
    Snímek obrazovky (3).jpg
     

    Attached Files:

  2. BoogieD

    BoogieD

    Joined:
    Jun 8, 2016
    Posts:
    236
    Perhaps you should not rely on colliders to guide the train bogie along the track. It's likely to be problematic and not necessary. Just get the bogies to follow a spline curve based on the track center line. That will require no calculations or issues from the physics system at all.

    Real railway bogies have an issue called 'sinusoidal oscillation' as they roll along the track. The wheels typically have a 3% tread taper with a fillet to center them on the rail preventing flange wear but that also causes the oscillation. You have a trench with an angled bottom to guide your wheels instead. Perhaps you are experiencing something similar with the physics engine. It is likely however that the problem is something more fundamental and more to do with how physics engine colliders collide.
     
    Last edited: Sep 16, 2017
  3. LegalHax

    LegalHax

    Joined:
    Sep 16, 2017
    Posts:
    2
    Perhaps it is the best and easiest solution for my game. What can i do is make the train (bogie) will follow curve and wheels will follow colliders (inequality of the track) without affecting the train for more realism. Or i can add animations for it.

    Thank you so much.
     
  4. BoogieD

    BoogieD

    Joined:
    Jun 8, 2016
    Posts:
    236
    You can just make the train follow along a spline or bezier curve. http://answers.unity3d.com/questions/12689/moving-an-object-along-a-bezier-curve.html
    If you want the train to bump or jolt to make it less smooth for realism you can just slightly change the lateral position as you move forward perhaps with a random number or use something like a camera shake asset on the bogie.
    Using the physics engine to make a train stay on the rails is just overkill and problematic unless there is a specific reason to do so. It is a simple enough thing to do just with code if you just want to make a train go along some rails.
    What you should ideally do is make your track mesh generate from the same bezier curve too then everything is together and ready to go.