Search Unity

U5 - Rigidbody, mesh collider & trigger problems.

Discussion in 'Physics' started by LastLance, Mar 4, 2015.

  1. LastLance

    LastLance

    Joined:
    Feb 22, 2015
    Posts:
    52
    i'v got object with 10 parts, parts 1-3 use like collision mask: convex + ignor raycast layer. 5-7 parts, needs only "trigger for raycasts", so, got problems:
    1 - error "Non-convex MeshColliders with non-kinematic Rigidbodies are no longer supported in Unity 5.0." but, realy, it's collide nicely (as i need for project, do not touch it please). But this error makes consol as red as USSR (3 error per main object, not collapsed, needs 10-30 objects of this type = 30-90 errors...). If it's about - rigidbody don't coolides BY non-convex mesh with others - ok, all works, but, errors...
    2 - if i need mesh, with ONLY raycast collision, but it gets holes etc (convex CAN'T be used) - what i'v need to do? Best solution for this - mesh collider -> trigger, but now i'v cant use trigger without convex...

    So, what magic i'v need for fix this?
     
    Last edited: Mar 4, 2015
  2. MortenSkaaning

    MortenSkaaning

    Joined:
    Jan 16, 2015
    Posts:
    120
    Hi LastLance,

    I'm not entirely sure what you are trying to accomplish. If you want to use your concave mesh for raycasting then you should not need to have IsTrigger enabled.
    If you want your object to not collide with anything then can you try to make a new collision layer and set this layer to not collide with anything? [I will get back to you with a more detailed way of doing this]

    Cheers,
    Morten
     
    Last edited: Mar 4, 2015
  3. LastLance

    LastLance

    Joined:
    Feb 22, 2015
    Posts:
    52
    i'v make new layer, it works, but feels uncomfortable. But main problem - errors about non-convex on rigidbody. Where i'v can say to engine - "yep, i'v know, skip it"?
     
  4. MortenSkaaning

    MortenSkaaning

    Joined:
    Jan 16, 2015
    Posts:
    120
    Hi,

    We currently don't have a way of ignoring individual errors and I agree that it would be nice to have :) It is something we are considering to add in the future.

    I still do not understand why you would set the Collider to be a trigger, except to make it ignore collisions.
    We will consider adding a "Enable Collision" property on a Collider, to make it take part in raycasts only. But it is not done yet so we will have to do the workaround. Maybe you nailed it on the first try, but please check this for reference.

    Cheers,
    Morten
     
  5. MortenSkaaning

    MortenSkaaning

    Joined:
    Jan 16, 2015
    Posts:
    120
    description is attached
     

    Attached Files:

  6. B.Deborn

    B.Deborn

    Joined:
    Mar 4, 2015
    Posts:
    2
    Rigidbody do not know "addforce" as example
     
  7. B.Deborn

    B.Deborn

    Joined:
    Mar 4, 2015
    Posts:
    2
    This means that i think it is a problem in C Sharp. The Compiler is missing some statements.
     
  8. MortenSkaaning

    MortenSkaaning

    Joined:
    Jan 16, 2015
    Posts:
    120
    Hi B.Deborn,

    I think you posted on the wrong thread?

    Cheers
     
  9. LastLance

    LastLance

    Joined:
    Feb 22, 2015
    Posts:
    52
    as i'v say - i'v already use this method, but feels lightly uncomfortable about this (earlyer uses "trigger" marks) at last - it works, so its not a real probem. But "error problem" (
    Non-convex MeshColliders with non-kinematic Rigidbodies are no longer supported in Unity 5.0.
    ) realy get me crazy, without "magic button - yep, i'v know, skip and go".
     
  10. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    637
    @MortenSkaaning Something *is* going wrong with triggers/colliders in U5.
    I'm having issues with a OnTriggerExit script that worked as it should in U4.6.3.
    I'm never killing my player, i'm only disabling the rendered and them moving the camera to the last checkpoint and then re-enabling the renderer. The script would reset the camera's angle and distance to suit a section in the level.
    In 4.6.3 the camera would reset and recenter, but in U5, OnTriggerExit isn't triggered anymore and the camera won't reset. And i'm using a box collider as a trigger.

    P.S. i tried using ontriggerstay and it wouldn't recognize that the object is no longer in the volume.
     
  11. MortenSkaaning

    MortenSkaaning

    Joined:
    Jan 16, 2015
    Posts:
    120
    Hi screenname_taken,

    Can I get you to file a bug report with a reproduction scene? The trigger issues are usually full of tricky details.

    Thanks
     
  12. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    637
    i'll try and do it tomorrow.
     
  13. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    637
    Yeap, it seems you can't teleport something to a place that is inside a trigger like before, (or teleport it right out)
    it has to go in or go out on, pass the boundaries. At least that's what happening to me.
     
  14. MortenSkaaning

    MortenSkaaning

    Joined:
    Jan 16, 2015
    Posts:
    120
    That is very unfortunate! Can I please get you to submit a bug?
     
  15. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    637
    i did a submission, mentioning 2 things.
     
  16. LastLance

    LastLance

    Joined:
    Feb 22, 2015
    Posts:
    52
    So, will u fix errors about non-collision? Coz it's spaming like crazy, and eats 54% of system for this.
     

    Attached Files:

    • gg2.PNG
      gg2.PNG
      File size:
      19.5 KB
      Views:
      786
    • gg1.PNG
      gg1.PNG
      File size:
      21.4 KB
      Views:
      827
  17. MortenSkaaning

    MortenSkaaning

    Joined:
    Jan 16, 2015
    Posts:
    120
    @LastLance, we will eventually fix it. But you should really fix the setup. You get a lot of errors because you like have a triangle mesh on a dynamic object. That is not supported by PhysX. Unity keeps trying re-initialize the setup and that's why you get a lot of error spam.
     
  18. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    637
    About that, just a curiosity question, is the algorithm in unity that makes the convex meshes different than U4.6.3?
    I noticed that a couple of triggers were kinda different in U5 than U4.6.x when i clicked on convex.
     
  19. LastLance

    LastLance

    Joined:
    Feb 22, 2015
    Posts:
    52
    Ok, i'v got a truck, and, i'v need to put bullet-hit decals on it. How i'v need to do it? Basicly - main physical colision make by convex mesh + trigger mesh for raycast hits. Now - only convex on rigidbody, so, raycast hits it in air, not on mesh surface. So, i'v need to set 20-30 lowpoly meshs with convex to fix it..... And it costs lot of time + i'v got: 8 wheels, 3 main collision meshs, 20 lowpoly ray-detect meshs, 8 truck parts meshs, and all that per 1 truck. FPS don't like this method. So, what the best solution for this gameset u can advice for me?
     
  20. MT3

    MT3

    Joined:
    Nov 14, 2013
    Posts:
    12
    Perhaps this is the wrong place to post this... I apologize if it is, but I am getting hundreds of these errors in a large project with many scenes. The most frustrating aspect of this is that it tells me nothing about the source of the error... Why? If you can detect the error, surely you can report the source of the error! Some of my scenes instantiate many objects, so simply examining the scene isn't comprehensive. Checking game objects is a possibility of course, but why should we have to do this? PLEASE add source of error to this error message! Can't imagine why it's not there now...
     
  21. LastLance

    LastLance

    Joined:
    Feb 22, 2015
    Posts:
    52
    If u make big project - best use u4.6, or wait u5 with physics fix. New system of collision real pain in... Worst thing - if u need non-convex collision on rigidbody for raycasts.
     
  22. MT3

    MT3

    Joined:
    Nov 14, 2013
    Posts:
    12
    Those words were echoing in my head... Thanks for confirming the simplicity of the answer. After sleeping on this I came to realize that I had already changed everything that "should" produce this error, yet the error persist. I suspect this is the "best" option for many people and it helps (helped me) to see it in print :confused:

    Perhaps my conundrum was seated in the fact that I have come to trust Unity to produce amazingly stable and user friendly tools right out of the box. This seems a bit "beta" for a Unity release, but I also trust them to make it right, they always do. ...and how convenient that 5 installs alongside instead of over 4!

    Thanks again!
     
  23. LastLance

    LastLance

    Joined:
    Feb 22, 2015
    Posts:
    52
    yep, same feels - start once with u2.6 - userfriendly + stable + powerfull tool. Nicly, untill u5... But, everyone makes mistakes. About returning to u4.6 - evry time when u walking around solutions - u wasting u'r time. Sometimes u need just take one and go forward.
     
  24. aaron568

    aaron568

    Joined:
    Mar 15, 2015
    Posts:
    1
    This is ridiculous. Why would you get rid of non-convex mesh triggers? Now I can not even check if a gameobject has entered an L shaped area. The only option is to move the collider to a no-collision layer, but that makes the interaction between them useless. I understand that maybe the new engine does not work like that, but you need non-convex triggers.

    MortenSkaaning
    Unity Technologies
     
  25. LastLance

    LastLance

    Joined:
    Feb 22, 2015
    Posts:
    52
    i'v realy don't know, how to makes properly collision layer (for bullet hit decals, decals at all, etc) on vehicle (rigidbody) on u5. And i'v got no L or H or T likes meshs, they closly to "@*&^%)*@!$" mesh, so, for ray-detect collision, i'v need closly to 30 convex meshs per vehicle...
     
  26. MortenSkaaning

    MortenSkaaning

    Joined:
    Jan 16, 2015
    Posts:
    120
    The support for triangle mesh triggers was removed inside PhysX. The decision was likely motivated by the lack of symmetry guarantees that comes with using a triangle soup. I.e. if there are holes then it is not possible to tell if an object has exitted a trigger, once it has entered it.
    We know that the current situation is a bit clumbersome. One of the next tasks we have lined up - aside from fixing bugs - is adding support for automatically generating convex meshes out of a triangle mesh, like HACD http://sourceforge.net/projects/hacd/. We can't make any specific timeline promises other than we know that it is important to have.
     
  27. LastLance

    LastLance

    Joined:
    Feb 22, 2015
    Posts:
    52
    yes, imortant. 1\3 of all gameplay (in my project) based on ray-detect with mid-poly mesh on rigidbody platform. now - i'v absolutly can't use it. Any chance get u5 with old physics? Still works with u4.6...
     
  28. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    637
    @LastLance Don't expect that to happen, I think it would mean to compile U5 with the old PhysX SDK.
     
  29. swokes

    swokes

    Joined:
    Jun 30, 2013
    Posts:
    4
    I just upgraded to unity 5 and got caught out by this problem. I need to do raycasts against non-convex mesh colliders, but now I cant do this.

    I have complex voxel based objects which each have a convex collider for physical interaction and a non-convex collider which I used for ray casts. This allowed physical interaction to be modelled crudely with the convex hull, but allowed my projectiles and magic to interact precisely with the object via the ray casts. I could blast a ray of fire through the object and it would come out the other side. But in unity 5, it refuses to use the non-convex mesh collider, so the magic system is broken.

    What I find most annoying is that this is not mentioned anywhere in the release notes of unity 5, which I read through before installing it. This is significant change to the physics engine and I feel it should have been mentioned here.

    I'm now faced with three choices - 1) completely rethink / rewrite the magic system 2) Go back to unity 4.6 or 3) Give up with unity. Option 3 is probably not practical due to the time invested in unity, but its what I felt like doing once I discovered the problem. Option 2 is messy, and I miss out on some of the better things in unity 5, but at the moment I think its my best option.
     
  30. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    637
    If your meshes already have convex colliders, then you may just need to click on the"convex" tick box in their collider.
     
  31. swokes

    swokes

    Joined:
    Jun 30, 2013
    Posts:
    4
    But it doesn't work when the shape is intrinsically non-convex. The collision point is at the wrong place. Instead of burning a hole through the object, the raycast keeps hitting the same point on the "convex mesh" approximation to the real mesh. Its the same problem that LastLance mentioned with floating decals.

    Now given that my objects are voxel based its possible I can work around this and write some script to take the false impact point, the direction of the raycast and manually search for voxels along that line that are active to find an approximate "hit point". This is messy but might just work. But its particularly frustrating because in unity 4.6 this just worked so smoothly. And this solution will not work for non-voxel based objects, so LastLance is still stuck :(

    Anyway, I guess I better start coding something up.
     
  32. MortenSkaaning

    MortenSkaaning

    Joined:
    Jan 16, 2015
    Posts:
    120
    Hi swokes

    Just to say it again, the support for non-convex meshes is not something we deliberately have crippled. The support was removed inside PhysX and you guys are the first to give us specific feedback on this. The situation will be improved in the future (tm).

    If you only need to do raycasting against your mesh, as opposed to rigid body collision, a workaround using collision layers is here: http://forum.unity3d.com/attachments/disablecollision_workaround-pdf.129163/

    The two proper ways to do the raycast / mesh support in the future will be:
    1) Add automatic splitting of non-convex into multiple convex.
    2) Provide checkbox on Collider for "Participate in collisions".
     
    twobob likes this.
  33. swokes

    swokes

    Joined:
    Jun 30, 2013
    Posts:
    4
    Hi Morten

    I appreciate that the change was within PhysX, and I know unity had to upgrade its physics engine. Stuff like this happens in any big project. I just wish you informed us that this issue with non-convex colliders was going to change - I really couldn't find any mention of it anywhere, even in the unity blog about the new physics engine. That's my gripe.

    The solution for the future seems ok / workable. Are we talking unity 6 or some patch to unity 5? I just want to know whether its worth me doing my scripted solution or if I should wait a couple of months to see whether you fix the problem for me. Do you have a feel of the sort of time scale we are talking about here?

    The raycasting solution you talked about doesn't help if the mesh is non-convex and attached to a rigid body. My setup was:

    Top parent object with rigid body -> voxel shape with convex collider -> Same voxel shape with non-convex collider

    , where "->" shows the "parent -> child" relationship. So the rigidbody dynamics worked using the convex collider on the middle layer, and the magic raycasting worked against the non-convex collider on the bottom layer. I had already set up the layers in the way you suggested in the pdf, with the non-convex collider being in the "no collision" layer. The middle and bottom layer both used the same voxel mesh.

    In unity 4.6 this worked like a charm, but in the new unity 5 the bottom child no longer functions.

    Anyway, I've kind of accepted this is something I'm going to have to live with and work around. Apologies if I was a bit too angry before, it was just a bit of a nasty shock learning about this change.

    Thanks for your time
     
    Last edited: Mar 17, 2015
  34. ShilohGames

    ShilohGames

    Joined:
    Mar 24, 2014
    Posts:
    2,475
    This would be the ideal solution. Any idea when this feature will be added?
     
  35. jose_villalba

    jose_villalba

    Joined:
    Apr 13, 2013
    Posts:
    3
    I think I have the same problem, I have a few barrels and have a ball that can bring down the barrels or enter into the barrel, the barrel and the ball have different weights. In unity 4, when throwing the ball, if the ball has touched the barrel, the barrel moves, now with Unity5 I have the message "Non-convex non-kinematic MeshColliders With Rigidbodies are no longer supported in Unity 5.0."
    Is there any other way to do this?
    thanks!
     
  36. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    637
    Well, you'd have to make the barrel into a convex collider by ticking the convex tick box, but then the ball wouldn't be able to go in (I'm guessing the ball has a sphere collider instead of a mesh one).
    Or you could construct a composite collider for the barrel by using multiple tall box colliders and a cylindrical mesh for the bottom.
     
    jose_villalba likes this.
  37. jose_villalba

    jose_villalba

    Joined:
    Apr 13, 2013
    Posts:
    3
    thanks screenname_taken...
    Yes, by ticking the convex tick box the ball don't go in and I use a sphere collider...
    I will try your tips.
     
  38. Roni92

    Roni92

    Joined:
    Nov 29, 2013
    Posts:
    226
    But the error says "non-kinematic". So you could use primitives/convex meshes to detect collisions, and make your non-convex mesh collider without rigidbody(or with kinematic rb) as other object, just set its position and rotation every frame to match convex mesh, and use it to detect raycasts. And voila - you eat the cake, and you have the cake. The only problem is that you will have 2 time more colliders.
     
  39. LastLance

    LastLance

    Joined:
    Feb 22, 2015
    Posts:
    52
    Somehow it works, but if u got modular build system + network, it's all like - "Why we need legs when, we got crutch?". Some solutions / methods needs to be "sharped" up absolutly.
     
  40. Roni92

    Roni92

    Joined:
    Nov 29, 2013
    Posts:
    226
    Glad I could help ;)
     
  41. LastLance

    LastLance

    Joined:
    Feb 22, 2015
    Posts:
    52
    i'v try this solution 2 weeks ago...
     
  42. Tiberius1701

    Tiberius1701

    Joined:
    Sep 16, 2014
    Posts:
    53
    HI Morten -

    At this point, my game cannot be ported to console (since 4.6.4 is not supported) and I need the non-rigidbody non-convex functionality (it's how I get my ships to roll when they are hit by projectiles). My 4.6.4 version of the game also cannot be exported to the Mac App Store because of another Unity showstopper bug having to do with a GameKit not linking properly. The solution for the Mac App Store bug was to upgrade to 5.0!

    Do you have an ETA on this solution? It is the only thing holding me up currently.

    Thank you,
    Garry
     
  43. KingArbinV

    KingArbinV

    Joined:
    Apr 29, 2014
    Posts:
    8
    Im also having a problem with convex mesh colliders that need to be non-convex... One example is a cup that holds pencils on a desk.. I want the cup to be moveable, able to be knocked over but at the same time, it able to hold the pencils before its knocked over..

    Another example is the desk itself.. I want the desk to be able to be knocked over, allow players to hide under it, the drawers able to move, and able to hold things inside them.

    I can't necessarily do any of this with the system how it is now. I designed all these models myself with that in mind.. I don't really like all the things PhysX has broken too much, you guys should fix it first thing and it should be number 1 on priorities..
     
  44. gian-reto-alig

    gian-reto-alig

    Joined:
    Apr 30, 2013
    Posts:
    756
    Okay, need to tune in here too

    This problem is also occuring in my Unity 5 rebuild of my prior Unity 4 project.
    Now, I have actually a much more complicated setup, As I have a damage system that raycasts against mesh colliders for armour penetration and module damage.

    Now, the whole mesh is cut up into armour sections to make it possible to give different sections different armour.
    In Unity 4, that was easy to do. Just used non-convex mesh triggers, triggers so they wouldn't interact with the physics but would with raycasts, non-convex so the complex mesh shape was preserved and the raycast would only trigger once!

    Of course now with Unity 5 I get swamped by these errors. And the work around listed don't sound like they would work in my case. I NEED mesh non-convex colliders, and it seems mesh only work any longer in a convex state.


    Any kind of convex mesh is completly unusable for such a setup. For one, complex concave armour sections would need to be cut up into many sub-meshes so that the convexity wouldn't ruin the shape, and then there is no guarantee any longer that the raycast only hits once (What happens when it exits the collider?), or the convex mesh wouldn't extend to where it shouldn't be (because the armour should be a thin layer on the surface).

    1) Will there be a solution not involving convex meshes, or at least that emulate a non-convex mesh to the point that
    a) there is no depth to a onesided or twosided, "flat" mesh so that the collider is basically just a mesh surface?
    b) the mesh is emulated exactly without any simplification?
    2) What is the ETA to such a solution (if it takes years, that means I will have to either abandon PhysX or Unity 5)?


    The only solution that actually might work for me... but it is so incredibly ugly that I rather try everything else first.


    Seems its time to leave PhysX in the dust and see if one of the custom physics engines from the Asset Store can do a better job...
     
  45. MortenSkaaning

    MortenSkaaning

    Joined:
    Jan 16, 2015
    Posts:
    120
    Hi gian-reto alig,

    There is a workaround that makes raycasts work with convex meshes.
    1) Use only MeshCollider, not Rigidbody, on the concave meshes you want to raycast against.
    2) Manually disable collision of the MeshCollider by adding a "NoCollision" collision layer, as shown here: forum.unity3d.com/attachments/disablecollision_workaround-pdf.129163/

    You should be able to raycast against the meshes now. This solution is feasible because it is no longer expensive to move static colliders in Unity5.

    We are actively working on a convex decomposition solution, but it is still too early to give an ETA.

    Regards,
    Morten
     
    Last edited: May 1, 2015
    twobob likes this.
  46. gian-reto-alig

    gian-reto-alig

    Joined:
    Apr 30, 2013
    Posts:
    756
    That would be the not-so-nice but usable workaround someone else already mentioned.
    Well, I guess that would be my last resort then.

    Thanks for the answer anyway...


    Regards

    Gian-Reto
     
  47. LastLance

    LastLance

    Joined:
    Feb 22, 2015
    Posts:
    52
    So, what i'v need to do, if, i want to raycast-hit high/mid-poly vehicle, for bulletprints? Vehicle = rigidbody, convexed collider = bulletprints in air, separate rigidbody and collision forms and use "collision.pos = rig.pos;" turn it in headake... So, what closest solution for nice resoult?
     
  48. MT3

    MT3

    Joined:
    Nov 14, 2013
    Posts:
    12

    Mort,

    First thanks for the replies you have provided.

    At present we have halted development of a large project. The unexpected physics changes introduced in U5 have completely broken hundreds of hours of development on physics based game play. We are forced to shelve this development until there is some resolution that gives us a reason to believe we will be able to continue both development and updates to the released game, without fear our engine will break our project if we attempt to use the current version. Neither do we do not find it propitious to continue development with a version of the engine that can not be updated.

    We have great faith in Unity's ability and desire to correct this issue for it's customers. Our deepest concern lies in the fact that elements of Unity are produced by third party developers who, at least in this case, make no allowance for backward compatibility. This creates the unfortunate circumstance that at any time Unity could introduce application breaking changes to it's engine. In the current case the change was unannounced and the breadth of the problems introduced to existing projects was, apparently, not anticipated.

    If I may be blunt... I believe Unity must, by this time, be a valued customer of PhysX. If Unity requires backward compatibility from PhysX, I believe they and other partner/vendors would comply with your requirements. This seems so fundamental to Unity's expressed and delivered purpose of providing the most usable game engine in the world, that it must be considered. I hope that at some point you can reassure us that is the direction Unity will continue to take.

    M Miles
     
  49. MortenSkaaning

    MortenSkaaning

    Joined:
    Jan 16, 2015
    Posts:
    120
    Hi, I can't undo the past, but I can assure you that we don't want to repeat this process again.

    I just learned of a better way of disabling raycasting, though it only works from 5.3 onwards. You can use "Rigidbody.detectCollisions = false", but it only from script.
     
  50. mar10

    mar10

    Joined:
    Jan 30, 2014
    Posts:
    11
    HI there, when I updated my project to 5.3.5f1 I noticed that with some of my map buildings that have mesh colliders; with mild jagged edges that when my capsule collider makes contact with the edges it becomes jittered and then suddenly teleports in 5.1.1f1 this does not happen so I have been stuck using that version of unity and will likely build the final game in that version. I hope someone in unity can shed some light. thanks.