Search Unity

Colliders go through each other for a few frames; is this acceptable visually since its so short?

Discussion in 'Physics' started by tfishell, Nov 8, 2018.

  1. tfishell

    tfishell

    Joined:
    Nov 20, 2017
    Posts:
    97
    This is just something I've been wondering for a while. I'm working on a 2D platformer, and the collider2d on the player/dynamic rigidbody2d goes through the ground/boxcollider2d for a few frames. I assume for a small cheap beginner game this is acceptable visually. (I believe the "through each other for a few frames" could be avoided using kinematic + scripting - I have been following a Sebastian Lague tutorial that seems to do this - but I'd prefer not to worry about that right now because I have plenty left to try to do and learn for the game.) In any case, I was curious what recommendations folks here have or what the "standard(s)" are. Thanks.

    Gif: https://imgur.com/504oziu
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    tfishell likes this.
  3. tfishell

    tfishell

    Joined:
    Nov 20, 2017
    Posts:
    97
    I actually hadn't really, thanks. Is it recommended to switch the mode via scripting depending on the velocity or the difference in position between frames ("delta movement"?), or is it okay to leave it as "Continuous" if my work isn't graphically intensive or not many gameobjects onscreen at once?
     
  4. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    That's an interesting question. I've never dynamically changed the Collision Detection Mode. I always decide on it based on the expected behavior of the object, depending on how fast I think it will be moving. I'm not sure whether there are any issues with changing it on the fly, though I can imagine some cases where that might result in a bad outcome. Such as: what if a stationary object is struck by a very fast moving object. I'd probably just leave it as Continuous unless it's an actual performance issue. (Assuming Continuous actually does help keep your object from penetrating the floor as much.)
     
    tfishell likes this.
  5. tfishell

    tfishell

    Joined:
    Nov 20, 2017
    Posts:
    97
    Absolutely in my case.