Search Unity

Weird terrain physics.

Discussion in 'Editor & General Support' started by Nemox, Jan 2, 2012.

  1. Nemox

    Nemox

    Joined:
    Feb 16, 2010
    Posts:
    396
    So I'm messing around with my physics-based character control system, and the terrain physics seem really off. I tested it with a ball. Its material was completely frictionless and bounceless with minimum combination. Sure enough, the ball would absolutely not stop due to friction while sliding horizontally across terrain. However, while sliding down a slope its movement becomes much slower, as though gravity weren't pulling on it as strongly, or as though friction actually were acting upon it.

    And something else quite strange as well. When it's sliding across, then hits an upward hill, logically if friction is playing some part or something, it should have some effect to slow it, but the ball moves upward faster than it did on flat land. Gravity also does very little to affect its movement; it will eventually slow down, but it obviously isn't a major player here.

    What's going on with Unity's terrain physics? And is there any way to fix it, short of replacing the whole terrain system altogether?


    Note: This has been happening for me with both 3.4 and 3.5. I'm fairly certain it happened in earlier versions too.
     
    Last edited: Jan 2, 2012
  2. SmilingCatEntertainment

    SmilingCatEntertainment

    Joined:
    Jun 8, 2013
    Posts:
    91
    LSS: Turn up your Solver Iteration Count

    I know this thread is old, but this problem plagued me as well for months and want to make sure that no one else suffers this behavior unnecessarily, since my many attempts at searching these forums did not provide the simple answer to this very real and frustrating problem.

    In an attempt to troubleshoot this, I went as far as to create a separate mesh collider with the same geometry as part of my terrain, and they indeed behaved differently. The mesh collider worked properly, but the terrain collider had weird behavior including objects sliding uphill and friction not working in general.

    I even made a minimal scene in my game project that demonstrated this behavior, exported it as a package, brought it into a new project to get a bug report ready, and lo - in the new project everything worked fine.

    Fuddled and beboggled, I decided to compare project physics settings - Some quick testing by setting one setting at a time back to the default revealed that the problem was my Solver Iteration Count setting. I had turned it way down (1), because I have a lot of objects, but their physics don't need to be terribly accurate. Apparently that is too low for the terrain collider to deal with.

    When Solver Iteration Count is set to 1, the problem is the most severe. Setting it to 2 mostly fixed it for me, with some objects sliding for a brief period. I did not notice any artifacts at all when set to 3.

    Hopefully this saves some others hours of pain.