Search Unity

Colliders randomly stops working

Discussion in 'Physics' started by Hertzole, May 22, 2016.

  1. Hertzole

    Hertzole

    Joined:
    Jul 27, 2013
    Posts:
    422
    Hi

    I am working on a school project with a group and since we don't have a lot of time, we use cubes with box colliders for basically everything. And now when I've been playing a bit I noticed that sometimes the box colliders just stop working. The player can walk straight through them but raycasts seem to detect that they are there. The collider component is not set to trigger and is enabled. The worst part is that it is completely random and we can not foresee what block it will target next and we can't see if a block has been targeted unless we walk into it.

    We've never seen anything like this before until we updated to Unity 5.3.5. And since we updated to Unity 5.3.5 the day we began with the project we're not sure if it is a bug or something is wrong with the game.
    I am currently taking it up to myself to test it in Unity 5.4 beta 18 to see if the problem is there. Since I need to play the level over and over again it will take some time.
    But in the meantime, I would like to ask, has anyone else experienced this? Is this a Unity bug or something wrong with our game?
     
    Last edited: May 22, 2016
  2. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    most likely the way you move your cubes..

    show us your code.
     
  3. Hertzole

    Hertzole

    Joined:
    Jul 27, 2013
    Posts:
    422
    But I am not moving any cubes.
     
  4. Hertzole

    Hertzole

    Joined:
    Jul 27, 2013
    Posts:
    422
    I just found a cube where the collider stopped working. I am currently in Unity 5.3.5f1 since Unity Beta 5.4b18 was really laggy for me.
    What I can see there's nothing wrong with the cube.

    That Object Data Manager just stores data about the object and has some handy functions to get that data. It never actually does something with the colliders.

    Why is this happening? We are getting close to our deadline and having this bug in the game would be REALLY bad!
     
  5. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    Is your collider the same size as your object?
     
  6. Hertzole

    Hertzole

    Joined:
    Jul 27, 2013
    Posts:
    422
    The object itself gets resized and the box colliders follows, so yes, it is the same same as the object.
     
  7. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    Does it have a rigidbody attached? (This has at one point been inconsistent / changed between unity versions)

    Easiest is to post your code...
     
  8. Hertzole

    Hertzole

    Joined:
    Jul 27, 2013
    Posts:
    422
    It has never had a rigidbody attached. The only thing that has a rigidbody is my player, that also has a character controller, and that rigidbody is set to kinematic.
    Also, when it comes to code, I have no idea what code I should post.
     
  9. krisu

    krisu

    Joined:
    Jul 10, 2013
    Posts:
    40
    I had similar problem. Just some colliders stop working and your character just fall through the floor or not colliding with wall.
    This is not happen if you make your own CharacterController by making RigidBody with CapsuleCollider.
    Orginal Unity CharacterControler still is bugged.

    Here is code to reproduce this bug:
    http://forum.unity3d.com/threads/unity5f4-bug-in-charactercontroller.310715/
     
    Hertzole likes this.
  10. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    i am still learning unity myself, but your last comment makes me wonder. If your player is kinematic and your block has only a collider, you are not using the physics engine to move your objects. It is likely that this is the reason for your issue.

    Try a rigidbody (kinematic) on the block
    Move the player with add force (i.e. Let the physics engine move the player) - rigidbody (not kinematic)

    Code: movement script of the player
     
    Last edited: May 23, 2016
  11. Hertzole

    Hertzole

    Joined:
    Jul 27, 2013
    Posts:
    422
    Thank you! That script is very handy and it allowed me to test a few things.
    With the help from krisu's script, I could test the player a few times on a lot of blocks. I've come to the conclusion that even if I add a rigidbody and set it to kinematic it won't work.

    So I've come to the conclusion that I need to make a rigidbody player then. What a bummer. :/
     
  12. OneManArmy3D

    OneManArmy3D

    Joined:
    Jun 2, 2011
    Posts:
    191
    This bug is long time in unity engine (definitely more then 6 months).
    I saw this bug in editor and also many times in game. Character controller for some reason does not collide with some scene object(collider). It can be Box, Mesh or even terrain collider.
    Problem must be in Character Controller, because when player respawns everything again is fine.
    I doubt that we can somehow reproduce this bug, to report (it happens randomly).

    Actually i would like to hear "official" answer... is there any progress to find/fix this critical bug?
    And if someone saw other topics (about this bug), please leave a link.
     
  13. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    Critical bug? Get real. Not even a bug. This is a user implementation failure.
     
  14. OneManArmy3D

    OneManArmy3D

    Joined:
    Jun 2, 2011
    Posts:
    191
    When character controller has no collision with some colliders in scene, it's not a bug?
    When players can walk through some objects, or fall through ground, it's not critical bug?
    So, what is your suggestion? Don't use CC?
     
  15. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    Read the physics documentation so you have an understanding of why something doesnt collide. There are many reasons collisions dont occur, none of them bugs.

    To flip your question, would I use CC? nope.
     
  16. OneManArmy3D

    OneManArmy3D

    Joined:
    Jun 2, 2011
    Posts:
    191
    believe me i have read and i know how everything must function. And please don't write here (your comments are useless).
     
  17. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    lol. useless eh... at least I know how to use the physics system properly.
     
  18. OneManArmy3D

    OneManArmy3D

    Joined:
    Jun 2, 2011
    Posts:
    191
    one more useless comment... maybe moderator will give you warning?!
     
    TreacherousLetch likes this.
  19. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    I've helped significantly more people on this forum than you ever will. Take your butthurt elsewhere.
     
    firegate666 and slojanko like this.
  20. OneManArmy3D

    OneManArmy3D

    Joined:
    Jun 2, 2011
    Posts:
    191
    I see, in this forum you are top spammer.
    You are not even trying to help here, so i am asking again -please don't write here.
     
  21. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    lol.. do you always go around being so stupid? My first post was to request op's code so I could help... you on the other hand... too busy being butt hurt about being told the problem is you, rather than the engine. So why dont you go away, because you are definitely not helping with any of your posts.
     
  22. OneManArmy3D

    OneManArmy3D

    Joined:
    Jun 2, 2011
    Posts:
    191
    Calm down. No need to be rude.
    Then be so kind and explain to us, why it happens. What we are doing wrong?
     
    TreacherousLetch and ModLunar like this.
  23. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    take a leaf out of your own book...


    The answer to what you are doing wrong... pebkac
     
  24. OneManArmy3D

    OneManArmy3D

    Joined:
    Jun 2, 2011
    Posts:
    191
    So this is how you are helping here? lol
    Can you normally answer on my question?
     
    TreacherousLetch likes this.
  25. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    I didnt come here to help you, and I now I wouldnt help you if you paid me.
     
  26. OneManArmy3D

    OneManArmy3D

    Joined:
    Jun 2, 2011
    Posts:
    191
    If you don't use CC (in unity 5) = you have never saw this bug = you have no idea what is going on.
     
  27. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    Im not so clueless as to need to... anyway, ive derailed this thread arguing with your dumbass enough. im adding you to my ignore list.
     
  28. Daniel-Strayer

    Daniel-Strayer

    Joined:
    Apr 16, 2013
    Posts:
    68
    JamesLeeNZ - You are one of the most unprofessional posters I have seen in some time. There is no reason for you to be nagging OneManArmy3D in this thread. I have also experienced static box colliders randomly ceasing to collide with character controller setups for no apparent reason. There indeed seems to be a problem here. JamesLeeNZ - I will NOT respond to posts by you in this thread. Take your trolling elsewhere. As for RealMTG's and OneManArmy3D's concerns, I am here to acknowledge that there does appear to be an issue where box colliders seem to random cease to collide with character controllers. Exiting the collision and re-entering it verifies that the collision response is in fact not happening. I also have not been able to easily reproduce the issue due to the random nature, and the fact that everything is still set properly with regard to the physics setup.
     
  29. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    I offered help. Army went on like a nimrod, things escalated.

    I dont care what you think.
     
  30. OneManArmy3D

    OneManArmy3D

    Joined:
    Jun 2, 2011
    Posts:
    191
    "offered help" :D You only wrote that it is "user implementation failure" and "read the physics documentation". It is nothing more than SPAM.

    Seriously, maybe someone from physics team can look at this topic?
     
    Last edited: Jun 7, 2016
    BuzzKirill and ModLunar like this.
  31. OneManArmy3D

    OneManArmy3D

    Joined:
    Jun 2, 2011
    Posts:
    191
    I found few videos.
    Players reported this bug:


    As you can see players does not collide with one of containers.

    These containers has box collider attached, but it can be any object/collider in scene (box, mesh, terrain doesn't matter).

    When player respawns, he again has collision with container.
    I saw this bug 2 times in editor and i can confirm that everything is ok with layers/colliders.

    I found one more video (time around 3:13):
     
    Last edited: Jun 7, 2016
  32. MegadethRocks

    MegadethRocks

    Joined:
    Dec 12, 2009
    Posts:
    162
    We've had this happening in our game as well. It had been working well for a few years, but something got messed up in the change to 5.x and our players were randomly falling through colliders and walking through walls. We had to write our own version of the character controller to get things working correctly. All of the physics functions work perfectly so it's easy to fix, but it's weird that Unity's controller became unstable in 5.
     
    JamesLeeNZ likes this.
  33. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    @MegadethRocks pretty much confirmed what I said... I've never had any collision issues with Unity.
     
  34. OneManArmy3D

    OneManArmy3D

    Joined:
    Jun 2, 2011
    Posts:
    191
    you said "Not even a bug. This is a user implementation failure" and "Read the physics documentation".
    you never had any collision issues, because you are not using CC in unity 5, but many devs are using it.

    not everyone wants/can write own version of the character controller like MegadethRocks did.
    there is bug and this bug must be fixed ASAP.

    maybe moderators can pass link to someone, who can give any details on this topic?

     
    TreacherousLetch and ModLunar like this.
  35. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    No devs of any worth. CC is not a unity core feature. Its a script that can be fixed by any dev that has anything between their ears. A script with a bug does not make the Unity engine buggy. Get that through your head and we might agree on something.
     
  36. OneManArmy3D

    OneManArmy3D

    Joined:
    Jun 2, 2011
    Posts:
    191
    JamesLeeNZ we are trying to inform that there is a problem and get some response, to understand what is going on. Are they aware? maybe they already working on it?
    But you are acting like an idiot.
     
    TreacherousLetch likes this.
  37. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    maybe you should learn to fix code yourself...
     
  38. OneManArmy3D

    OneManArmy3D

    Joined:
    Jun 2, 2011
    Posts:
    191
    someone here has a lot of free time...
    and what if they already found and fixed problem? sometimes is useful to ask!
    P.S. блин какой же ты тупой дебил...
    because of you this topic was turned into trash can.
     
    TreacherousLetch, Blarp and ModLunar like this.
  39. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    плакать больше ретардом
     
  40. Peris

    Peris

    Joined:
    Aug 8, 2012
    Posts:
    5
    I've been having this bug as well during the last year and it's driving me bonkers. The only "solution" I have found so far is to literally duplicate all collision to lessen the chance of it happening.
    My game uses procedural generation and I use a lot of box colliders. Every now and then, a random one will stop working. So far I haven't been able to consistently duplicate it. Even generating a level from the same seed, It'll be a random collider that just seems to stop working (resulting in you falling through the floor or clipping through a wall). It really does seem to be a bug on the unity side.

    I'll try to record video when I see it happening again. It really is something that needs to be tracked down, as it's a showstopper bug for my game.

    I also just want to say to @JamesLeeNZ .. please go be useless somewhere else if you have nothing to offer. Can't believe what I'm reading here.
     
    TreacherousLetch likes this.
  41. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    But its so much fun seeing how precious you are when I tell you that its not the engine at fault.

    Especially considering the engine is definitely not at fault.
     
  42. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    Do you have the collision set to continuous dynamic. It doesn't look like your moving that fast but maybe your getting through the collision volume.

    Are you doing something strange where you are using triggers rather then colliders on the box and forcing collisions in code? If so and you are using Physics.IgnoreCollision there is a bug that will reset trigger states and can make a collision exit/reenter the collider.

    if you set your block to static does this bug still happen? I have not had problems with two colliders missing (unless one is a trigger or a fast moving object is not set to continuous dynamic.)
     
  43. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    Sounds like theres actually a bug in the character controller. No one wants to fix it though.
     
  44. Bendik-Stang

    Bendik-Stang

    Joined:
    Dec 2, 2012
    Posts:
    3
    We are experiencing the same on PC/Mac, but not on the XboxOne build. It is completely random.
    Have even experienced it through the editor. It's fascinating to see the collider is there, and all is looking like it should, except the collision does not trigger.
     
  45. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    Interesting - I know it's already said, but is there some sort of example case that could be produced, sort of scene that shows this possible bug?

    I think I too have had issues with CC, but it was like year ago, can't remember exactly, it was most likely issue with grounded state detection not working accurately, be it my fault or not, I went on and used raycast.

    Below is a rant about CC, note that I'm pretty new to coding in general...
    --------------
    Anyway I kinda like CC;
    1. No need to use Physics system
    2. Using SimpleMove there is already built in gravity
    3. With Move it's possible to control gravity = jumping
    4. It does not suffer from "tunneling", you can set speed to ridiculously high, and it doesn't go through thinnest of walls
    5. Easy to limit slope walking

    Shame CC is not a plain MonoBehaviour script but component, it would probably eliminate all guesswork if it was possible to check the code. Also, it's mostly suitable for characters, not quadrupeds and such, but then again it's a Character Controller :)

    Rigidbodies - when I last time tried using CC (then went to rb objects), I did some reading, and came to conclusion that one shouldn't use Rigidbodies with CC, seems like it's best used as plain capsule it is, then have some movement script, It's a Collider, but also a special case, there are threads like this:
    http://answers.unity3d.com/questions/57680/should-a-character-controller-attach-with-rigidbod.html

    Movement - seems like it works in Update, FixedUpdate and LateUpdate all the same, I did some tests and it didn't seem to make difference what was used. But my testing was limited.

    Collisions - I think I also had some issues with collisions to rb's and like mentioned adding rb to CC itself might be not a good idea (or does it matter?) if using collision method OnControllerColliderHit then reacting by adding forces, I also did read threads like this:
    http://answers.unity3d.com/questions/206937/problem-with-charactercontroller-collision-detecti.html

    Alternatives - I also checked this ... but ended up liking original one better as it's simple for simpleton like me:
    https://roystanross.wordpress.com/downloads/

    Then again, as CC is bit of black box (unless I've missed the source code somehow) there are tutorials like this to get started with rb based character controller like advocated by @JamesLeeNZ and for above mentioned reasons:
    https://www.packtpub.com/books/content/unity-3x-scripting-character-controller-versus-rigidbody
     
    JamesLeeNZ likes this.
  46. Mr-Podunkian

    Mr-Podunkian

    Joined:
    Jan 21, 2013
    Posts:
    9
    I'm having the same issue here (Unity 5.3.3p3) with a title I've just shipped (http://store.steampowered.com/app/327510/). Like many of the users are mentioning here, it believe the problem to do with the CharacterController -- certain colliders randomly get ignored.

    It's not something that happens globally -- that is, I have multiple Character Controllers in the scene, and certain floors that allow the player to pass through will properly block enemy characters. Both player characters and enemy characters derive from the same class which handles all of the CharacterController movement via the Move function (not the SimpleMove function, because I like having very specific control over how my characters move). Similarly, I don't depend on CharacterController's "grounded" flag and have implemented my own.

    I've had to implement a workaround that places the player in a safe position, but I've noticed that this isn't just a freak one-time thing -- once a collider stops colliding with the character, it will continue to not properly collide with that character until a scene refresh.

    I've tried various things to try to rectify the issue, including replacing the quad-shaped mesh colliders with really thin box colliders, but the issue still seems to be occurring regardless. I've gotten bug reports near daily about this and have had to implement workarounds for the problem occurring, but this is very clearly an ENGINE-SIDE issue.

    I've seen this problem also affecting a game being developed by a friend of mine (http://store.steampowered.com/app/390030/), under similar circumstances -- while moving around the game level, certain level elements will just completely, and consistently fail to block collisions. Similar to my game, the player is re-positioned in the level after death via falling, the collider continues not to block the character's movement.

    I don't know if anyone's formally submitted a bug report for this, but seeing that it seems to be a widespread issue, it might be good to get some Unity Team eyes on the problem.

    Also, @JamesLeeNZ, it would probably be super helpful if you just kindly stopped trolling the thread with your unhelpful non-advice. It's pretty clear you're only here to condescend on people for using the CharacterController, which is, BELIEVE IT OR NOT, actually more performant and consistent than dealing with non-deterministic even-more-black-boxier PhysX simulation. The Unity documentation ITSELF states that you should use CharacterControllers for character physics if you don't need your characters to react with other physically simulated objects/don't need them to behave consistently with the PhysX simulation. Using the CharacterController also affords you the flexibility of not being limited to moving on FixedUpdate, and also of being able to move the character multiple times in a single frame and generating collision events for each move, which can be useful in separating out axes of movement and handling them separately.

    Unlike eses, I consider myself a very, very experienced Unity scripter, and it's transparently clear that you have no idea what you're talking about.
     
    Last edited: Jun 29, 2016
    SixteenBitsorBust and fairtree like this.
  47. RichyK

    RichyK

    Joined:
    Feb 8, 2015
    Posts:
    57
    I've got the same issue and it's not a user implementation issue. It occurs very randomly and quite infrequently, either with the result that my character controller is allowed to walk through a wall or even worse, falls straight through the floor. Now the floor is a prefab, and the floor pieces are all laid out in a grid, so every floor is identical. When the problem does arise and the character falls through the floor, I can pause the game in the editor, move the player back up above the floor, press play, and he'll fall back through it. If i move him back above the floor, highlight the floor piece, delete the floor, undo the delete, and press play, it all works again. Now tell me that isn't a bug in Unity ...

    Richard
     
  48. Mr-Podunkian

    Mr-Podunkian

    Joined:
    Jan 21, 2013
    Posts:
    9
    I did a cursory look at Unity issue tracker and didn't see anything that looks relevant, so I'll create a repro-scene and submit a formal bug report, which should hopefully be escalated as I'm a Unity Pro user. I'll keep you guys posted on what happens!
     
  49. RichyK

    RichyK

    Joined:
    Feb 8, 2015
    Posts:
    57
    Much appreciated! Thank you!!
     
  50. Mr-Podunkian

    Mr-Podunkian

    Joined:
    Jan 21, 2013
    Posts:
    9
    Hey everyone, just confirming that I've submitted the bug report, Case 809914. I included a simple test scene that shows the issue occurring pretty consistently (based off of a scene some other forum user put together), so hopefully it shouldn't be long until the bug is reproed and put into the issue tracker. I also mentioned that it's affecting my shipped title, so hopefully that should further expedite the process a bit. Hoping this gets fixed soon!
     
    ModLunar, 3pns, akuno and 5 others like this.