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. Dismiss Notice

Rigidbody "melting" through each other. Solved(?)

Discussion in 'Scripting' started by LuisDeliz, Jul 16, 2014.

  1. LuisDeliz

    LuisDeliz

    Joined:
    Nov 27, 2012
    Posts:
    24
    Hopefully this is the right area to post. This is a weird thing that happened recently.

    This is what it looks like:


    The player is not jumping on the box, the player is partially penetrating the box and then being expelled upward (by Unity Physics). This stops happening if I turn on isKinematic, but that's not a solution for my problem.

    The 2 boxes and the player have a Collider and a Rigidbody. The player movement is controlled through Rigidbody.AddForce(). Why is this happening? Rigidbodies shouldn't be going through each other.

    There is no downward pressure being applied to the player. It just falls with regular Unity gravity.

    I've tried physics solver count at 6, 15, 50, 100, 500. No difference.
    Timestep is set to 0.01.
    Max allowed is 0.1.

    Edit: Update
    More weird reactions:

    If I place the small cube on top of the large cube, it behaves correctly. If the player then lands on top of the large cube as well, the small cube + the player begin to "sink" into the larger cube.
     
    Last edited: Jul 16, 2014
  2. joni-giuro

    joni-giuro

    Joined:
    Nov 21, 2013
    Posts:
    435
    What kind of collider does the box have?
     
  3. sam268

    sam268

    Joined:
    Apr 21, 2014
    Posts:
    149
    LOL it looks funny....


    But in all seriousness I think that is a unity bug that I hope they fix in unity 5. I had this happen once to in a project I was working on, but was never able to fix it. it tends to happen when 3 or more rigidbodies are colliding at the same time it seems.
     
  4. cranky

    cranky

    Joined:
    Jun 11, 2014
    Posts:
    180
    What method are you using to move the player?

    EDIT: Nevermind, I missed that. Hmm, try changing the player's collision method to Continuous Dynamic?
     
  5. LuisDeliz

    LuisDeliz

    Joined:
    Nov 27, 2012
    Posts:
    24
    Regular Box Collider

    Its already set to Continuous Dynamic. I've also tried setting the boxes to that as well but no difference.
     
  6. LuisDeliz

    LuisDeliz

    Joined:
    Nov 27, 2012
    Posts:
    24
    I cleaned up the scene and left it at only 2 rigidbodies (player and 1 box), it still happens :( Very frustrating indeed.
     
  7. cranky

    cranky

    Joined:
    Jun 11, 2014
    Posts:
    180
    Can we see the code moving the player?
     
  8. LuisDeliz

    LuisDeliz

    Joined:
    Nov 27, 2012
    Posts:
    24
    90% of the code is from a popular Asset Store Script so I don't feel comfortable posting it. I've been in regular contact with the author and he has never seen this problem and has no solution. He thinks the answer might be some kind of Unity Physics setting.
     
  9. cranky

    cranky

    Joined:
    Jun 11, 2014
    Posts:
    180
    Ah, I see. Are your objects extremely tiny? Also check the Min Penetration for Penalty in the physics section.
     
  10. LuisDeliz

    LuisDeliz

    Joined:
    Nov 27, 2012
    Posts:
    24
    Nope. The small box is 1,1,1. The Player is ~1.8 units tall. I've even tried making the collider unplayably huge, it seems to help a bit but its still noticeable that some glitching is happening. I've also tried changing the player collider to a box collider, same results though it doesn't penetrate as deeply.

    Min Penetration is set to 0.01

    Thanks for the suggestions!
     
  11. LuisDeliz

    LuisDeliz

    Joined:
    Nov 27, 2012
    Posts:
    24
    Solved?

    I... don't know how or why. But its working.
    I decided to re-assemble my player asset. Not re-write any code, just literally assigned all the components to a new gameObject. My model, scripts, etc. And it all just works.

    Thanks to everybody that helped out!

     
    GarthSmith likes this.
  12. cranky

    cranky

    Joined:
    Jun 11, 2014
    Posts:
    180
    The second image sometimes describes me ;). Good to hear! Good luck with your game.