Search Unity

Collisions are not accurate

Discussion in 'Physics' started by GfK, Feb 17, 2015.

  1. GfK

    GfK

    Joined:
    Aug 15, 2014
    Posts:
    107
    I'm finding that collisions are inaccurate - is this normal?

    Screenshot below shows a pair of aircraft wheels - one wheel has a capsule collider which covers both wheels. The ground is a box collider (but it also fails with a meshcollider, too). The screenshot shows where OnCollisionEnter is firing, with the wheel still 0.02 away from the ground. Doesn't sound an awful lot but in my game scale, it's almost half the height of the wheel itself and is very noticeable.

    I tried various collision methods (continuous etc) but nothing helped.

    Other than scaling everything up to make this less obvious, is there another way around this?

    coll.png
     
  2. GfK

    GfK

    Joined:
    Aug 15, 2014
    Posts:
    107
    Typical - post on a forum, find the answer five minutes after (sort of).

    I discovered I can change the "Default Contact Offset" in Physics Manager. It was at 0.01, I've changed it to 0.001 which all but eradicates the problem.

    Is this a wise thing to do?
     
  3. GfK

    GfK

    Joined:
    Aug 15, 2014
    Posts:
    107
    Nobody??
     
  4. MatthewW

    MatthewW

    Joined:
    Nov 30, 2006
    Posts:
    1,356
    It's a fairly unwise thing to do, in that the physics engine is expecting units to be meters by default.

    It sounds like your game scale is pretty small if that's meant to be a full-size aircraft?

    (Other systems have defaults that make sense for meters too, i.e. camera settings, so it's worth standardizing)
     
    GfK likes this.
  5. GfK

    GfK

    Joined:
    Aug 15, 2014
    Posts:
    107
    Yeah it is pretty small - reason being that I started playing around with Unity 4.6, which imported everything at 0.1 scale (or was it 0.01? Either way I never understood the logic of it). Switched to Unity 5 and it imports models at a scale of 1, so I sort of adapted the models to fit the code instead of the other way around.

    No biggie though, I guess.
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can always just change the import scale. There's no reason to leave it at 0.1 if that doesn't get the results you want.

    --Eric
     
  7. GfK

    GfK

    Joined:
    Aug 15, 2014
    Posts:
    107
    Sure, though from memory, there was no way of changing the default value so everything had to be altered on a per-asset basis, and as I said, I never really understood the logic of importing everything so small. Admittedly I'm no Unity guru so may just have missed something.

    But it's a moot point really as I'm on Unity 5 now which defaults to 1. :)
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can select all the assets and change them at once.

    --Eric