- Home /
Friction Issue with Multiple Colliders Touching
EDIT:
Sorry about the image links being broken now; they were removed from where I was hosting them.
I've encountered an issue with multiple colliders touching, primarily evident when I am making a wall out of stacked boxes. When jumping against this wall, strange things will happen depending on the number of colliders that the jumping figure is in contact with at the start of the jump.
The following images illustrate my test. I have a figure (green) that can move side-to-side and jump, and has no physics material. The red boxes do not have rigidbodies, only box colliders. The text on the floating red box shows how many boxes occupy the same space (later images are tests when several boxes are duplicated in the same space). The text in the upper left shows the recorded top height of each jump.
First test: Image Missing
Second test: Image Missing
Another plain jump, but introducing the blue box collider I've used for this figure so it could jump against walls. This box collider has a frictionless physics material attached (all values on it have been set to 0, and the friction mode is minimum).
As you can see, the maximum height is the same.
Third test: Image Missing
Jumping while touching the single cube with friction. As expected when two colliders with friction run against each other, the jump isn't as high. The height value for this test, and other tests while there is friction, vary slightly.
Fourth test: Image Missing
The results of this test actually surprised me. This already presents an issue with friction in the physics system. The jump is actually higher than a plain jump! The height values for this test, and other frictionless tests, are consistent when repeated.
Fifth test: Image Missing
While I noted in test 3 that the value varies slightly each time it is repeated, it is consistently higher than any height produced in Test 3.
Sixth test: Image Missing
This is where things start getting really interesting. This is similar to the scenario I presented at the beginning, where a wall is made by stacking boxes. The jump height is noticeably higher than a plain jump.
Seventh test: Image Missing
And this is where all logic seems to go out the window (to me at least). If I duplicate the floating box 4 times, so the figure is in contact with 6 boxes simultaneously when it jumps, it goes much higher, and that is with friction! True, it goes up a bit slower and comes down slower, due to the increased friction, but it still isn't reasonable it actually goes that high.
Eight test: Image Missing
As you might have guessed from the pattern in the previous tests, having the frictionless component in contact with the 6 boxes allows an even higher jump. Not shown, I extended the boxes massively to see how high it would go. It went over 9 units high. Also noticeable, even though it is supposedly using a frictionless material, the rise and fall was slower than when it was not in contact with anything (if, at the top of that 9 unit jump, I moved the figure so it no longer contacted the boxes, it fell faster).
I hope I have sufficiently presented the issue. If anyone understands the issue, and better yet, if you know how to solve it, please let me know. Or if you think this should be submitted to a bug report or other location, just tell me where to go!
Answer by NinSonNar13 · Jun 28, 2014 at 02:32 PM
Looking around for similar problems, I found a form of a solution. There are differences in the way the physics engine handles collisions when colliders do or do not have a rigidbody component attached. It seems there are some issues with using static colliders (those without a rigidbody) in cases like this, so adding a rigidbody to the boxes, with it being set to kinematic to prevent movement, seems to solve it.
I had the same problem working on a 2.5D platform game (user is editing the levels, not the developer). I could not find any other solution. Thanks for the suggestion. While I suspect adding all those rigid bodies are expensive, it did solve my problem.
Well presented. I ran into this exact issue when building a 3d platformer. If the character (frictionless) jumps while in a corner touching more than one collider (also frictionless), it feels like friction is getting applied heavily and both the rise and fall are slowed (I've also seen the case where the jump height is actually increased like you described). This happens even without applying an input force to the player, ie absolutely zero XZ movement.
Adding a kinematic rigidbody did fix the problem for me as well, but I wish there was a better solution.
I do notice the problem comes back after I disable/re-enable one of the wall gameobjects at runtime though, so be careful.
Also, your links are broken.
Your answer
Follow this Question
Related Questions
Pallet falls through forks 2 Answers
Angular Friction 0 Answers
Collision detection for many colliders 0 Answers
Calculating Sphere vs. Plane Friction 1 Answer
Collision Precision 1 Answer