Search Unity

Rigidbody "pops" into the air when sliding along level surface

Discussion in 'Physics' started by victus_maestro, May 4, 2019.

  1. victus_maestro

    victus_maestro

    Joined:
    Apr 21, 2019
    Posts:
    21
    Hello all, sorry if this has been covered here but searches on the forums and online have yielded no results, except one which advocates changing physics settings that I would only do as a last resort.

    In short, the issue I have is:

    I have a player stand-in's capsule's rigidbody that is supposed to slide along a level surface along the x axis when walking or running, so I have an AddForce on the rigidbody's x based on the "Horizontal" input axis. However, when moving, the capsule has a tendency to pop up in the air as though hitting a bump, even though the surface is completely flat (the blockout shape is a plane).

    Additionally, the height of the "jump" seems directly proportional to the speed of the character.

    Now, I want to use physics because it won't always be just this straightforward motion and I like the idea of being able to manipulate things via friction and the like, but if this is a known problem with the rigidbody system, I'll have to consider alternatives.

    Has anybody experienced this and knows a good solution? I'll be kicking myself if it's some simple thing that I've been overlooking. Thanks in advance for any input!
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Are you using a plane (2D) or several "flattened" boxes (3D) put together as surface? To me, that looks like the second case, and the capsule is colliding with the vertical sides of the boxes.
     
  3. victus_maestro

    victus_maestro

    Joined:
    Apr 21, 2019
    Posts:
    21
    No, just a plane primitive, though scaled to 10 on the x axis to provide some running space.

    That would make sense, it seems to act like you would expect if there was a misalignment in the surface but it's one continuous collider.

    I don't recall ever seeing this problem before either, despite having used similar systems in the past.

    The only thing I could think of was that the collision detection was faulty and allowing for a brief intersection before overcorrecting and forcibly pushing the meshes apart, but I can't for the life of me think of why it would happen in this particular case.
     
  4. victus_maestro

    victus_maestro

    Joined:
    Apr 21, 2019
    Posts:
    21
  5. Ahndrakhul

    Ahndrakhul

    Joined:
    Mar 7, 2015
    Posts:
    23
    This happened to me when I was working on a project that used physics forces to slide objects across a flat surface. Even surfaces with no breaks in them caused my vehicle to hop, and I was using enough force that it would go flying off into the air. The only thing that ever worked for me was to change the "default contact offset" setting to something extremely low. The problem with fixing it that way is that if you set it too low, your object will jitter like crazy while at rest. You have to find the right balance. I never liked that solution, but it did seem to work. This also allowed me to transition between colliders smoothly.