Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Max Deprenetation Velocity in Physics 2D?

Discussion in '2D' started by LifeSymbiont, Mar 5, 2022.

  1. LifeSymbiont

    LifeSymbiont

    Joined:
    Apr 19, 2015
    Posts:
    36
    Hello. In the normal 3D Physics engine there is a setting under Edit - Project Settings - Physics called "Max Deprenetation Velocity" Which I set higher in my 3D games, so my player cannot slip through the colliders. In my current 2D Game AI Stories (Which is already on Steam) I wanted to increase the speed of my 2D controller beyond 60. But doing so causes the same "slipping through colliders" problem like in 3D.

    Is there some kind of setting like a "2D Max Deprenetation Velocity" in the project settings or else? I searched a bit and could not find one.

    Please help me.

    Edit: I FIXED IT!

    Edit - Project Settings - Physics 2D:

    Velocity Iterations: 20
    Position Iterations: 10
    Interpolation : None
    This way I can make the player faster without the slipping.
     
    Last edited: Mar 5, 2022
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,970
    This is typically addressed by setting collision mode to continuous.
     
  3. LifeSymbiont

    LifeSymbiont

    Joined:
    Apr 19, 2015
    Posts:
    36
    Thank you for the idea, but setting it to continuous and making it extrapolate does not help. The player still slips through after just walking into a wall long enough.
     
  4. LifeSymbiont

    LifeSymbiont

    Joined:
    Apr 19, 2015
    Posts:
    36
    I fixed it myself:
    Velocity Iterations: 20
    Position Iterations: 10
    Interpolation : None
    This way I can make the player faster without the slipping.
     
    Kurt-Dekker likes this.
  5. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,623
    What you're saying doesn't make sense. Interpolation/Extrapolation are an artifact of the Transform, not the body. Read Transform.position and Rigidbody2D.position to see this. Interpolation/Extrapolation update the Transform per-frame whilst the body is already at its position and doesn't move. This all happens outside of the actual simulation step.

    Interpolation is historic moving the Transform from the old body position to the current one. Extrapolation is predictive moving the Transform from the current body position to one predicted in the future based upon the current velocity. It doesn't drive what the body actually does at all!

    Continuous will stop the body at the point of contact, it won't penetrate at all. It'll only do that when using Discrete. This happens as part of the simulation step.

    I'm surprised you didn't see it then as it's right near the top described as "The scale factor that controls how fast overlaps are resolved.":
    scale-factor.png

    Physics2D.baumgarteScale controls overlap for Discrete. There's a separate one for Continuous (TOI). It's not a velocity but a scale in 2D (Box2D).