Search Unity

Physics samples character controller depenetration

Discussion in 'Physics for ECS' started by snacktime, Jul 4, 2020.

  1. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Trying to figure out what the bug is here exactly.

    Depen works fine until it's against a moving body where the velocity is in an opposing direction to the controller velocity. At that point the bodies just push through each other.

    I fixed up CreateConstraintFromHit so it sets the velocity on kinematic bodies and verified that the constraint velocity is being set. I though that must be it but while it makes a slight improvement the main bug is elsewhere still.
     
  2. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    So this seems to be a side effect of mixing velocity with direct transform manipulation. CollideAndIntegrate sets the transform position to a value that doesn't appear to match velocity. I'm using a very different set of logic to set the desired velocity so there might be some assumptions in the original code that make it actually match up correctly there. In any case switching to driving everything via velocity fixed the above and removed some jitter I had yet to track down. Seems like a good idea to only use velocity anyways.
     
    Zeffi likes this.
  3. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    This turned out to be an obvious error on my part, feeding the solver deltatime instead of fixeddeltatime. Since velocity driven objects use a timestep.
     
    petarmHavok and Zeffi like this.