Search Unity

Colliders on instantiated objects stopped working after 2018 update

Discussion in 'Physics' started by path14, Aug 4, 2018.

  1. path14

    path14

    Joined:
    Apr 9, 2017
    Posts:
    113
    Hey all. I just updated to Unity 2018.2.2f1 for the Mac and, well, as the title states, the colliders on instantiated objects stopped working. I can't collide with any mesh, box, etc. colliders in the editor, or the player. I'll report it as a bug if no one has a quick solution :)

    Thanks ahead of time for any suggestions!
     
  2. path14

    path14

    Joined:
    Apr 9, 2017
    Posts:
    113
    So, after some code-checking, I've concluded that the issue has to do with parenting objects with a collider on it. I'm not certain how I'll resolve it, but I'll figure something out. :p
     
  3. path14

    path14

    Joined:
    Apr 9, 2017
    Posts:
    113
    Let me continue my monologue :p

    Actually, I've found that parenting isn't always the issue. Instantiated prefabs with colliders as triggers aren't working either without any parenting done to them....so I'm stuck again.
     
    rahulk1991 likes this.
  4. 838nHex

    838nHex

    Joined:
    May 14, 2014
    Posts:
    14
    I have same problem. I could disable convex on the prefab. Then set convex to true after instanciating in code.
    then it works but still have some issues. it worked fine on 18.1.
    I think of switching back to the 18.1. especially because the convex colliders are not always usefull.
     
    NWHCoding and path14 like this.
  5. 838nHex

    838nHex

    Joined:
    May 14, 2014
    Posts:
    14
    or you can switch on of the convex checkmark on runtime after instanciating the prefab.
    that will make the collider work. what a disturbing bug.
     
    path14 likes this.
  6. Marcos-Elias

    Marcos-Elias

    Joined:
    Nov 1, 2014
    Posts:
    159
    path14 likes this.
  7. path14

    path14

    Joined:
    Apr 9, 2017
    Posts:
    113
    I'm glad I'm not the only one. Hopefully it'll get fixed soon, but at the moment I'm just turning it off and then back on in Start().
     
  8. A_World_Maker

    A_World_Maker

    Joined:
    Apr 21, 2018
    Posts:
    214
    I have just started using Unity with ernest, and noticed after the updated core programme, that nothing I do, makes any of my imported meshes collidable, they simply act like a large box. I can walk above or below, but not on/in.

    I create a mixture of scenes, inside building/rooms and those using a large mesh terrain. The previous version I could simply import my meshes/scenes and they would auto collide. I have checked every possible setting with both my own meshes, and those such as a rock from the asset store, and none will collide.

    I have checked the meshes in other platforms and they work flawlessly, so it must be Unity. They broke it?
     
  9. path14

    path14

    Joined:
    Apr 9, 2017
    Posts:
    113
    Make sure they're not set as "triggers". If you're using a mesh collider , you may have to make it convex if it has many faces / is complicated, or add a physics material to treat the collision. Maybe attach another collider (box, capsule, etc.). I suggest that because they're much more reliable. You can also check if the layers and collisions in the 'collision matrix' match up (If they don't then you might be ignoring collisions).

    My issue lies with instantiating the objects into the scene, so if that's your issue as well, then I'd suggest turning off & on the collider in a script. If they're not working without being instantiated, and if you've checked the other things, then I'm not sure what the issue could be.

    Code (CSharp):
    1.  
    2. void Start(){
    3. GetComponent<Collider>().enabled = false;
    4. GetComponent<Collider>().enabled = true;
    5. }
    6.  
     
    ShaneWinfred likes this.
  10. A_World_Maker

    A_World_Maker

    Joined:
    Apr 21, 2018
    Posts:
    214
    Hi path14,

    I am a Artist, not a coder, so none of that made sense to me. I uninstalled the 2018 version I had and went back to a 2017 version. Loaded the mesh, checked Collidable and all is good. I drove a car over it and the collision maps were almost 100%.

    There is also a bug in the OBJ importer, as it does not bring in and map any materials/textures, when I ran it through a FBX convertor, all was 100%.

    I use the same models in Unreal, I could only get a box collider from the OBJ importer, but when using it with Sansar, NeoAxis and many others, no issue.

    Needless to say, I will not be upgrading anytime soon. One of the downsides to all these updates is they do not seem backwardly compatible, often causing previous scenes to crash at startup. Unity is not Alpha it is passed Beta (albeit no software is truly out of beta), so there is an expectation that progressive updates, be progressive in fixing things, for me too many things are broken in the 2018 range of offerings and they get worse.

    There are some lesser known labels out there that do not suffer such things and feel far more polished. Setting collidable and materials is a one click affair, coders have their own trough to gorge from, but artists can create freely without errors breaking everything all the time.

    I've been dealing with VR or Immersive Environments as I prefer to call them, for nearly 20 years. Unity feels like a programme with only one part time contributor, rushing to get 'bug fixes' out of the door, only to create a cascade failure. If they want 5% of my earnings, they need to polish up their offerings before opening the till.
     
    Last edited: Aug 16, 2018
    rahulk1991 likes this.
  11. A_World_Maker

    A_World_Maker

    Joined:
    Apr 21, 2018
    Posts:
    214
    Oh, almost forgot, I also find few of the tutorials actually make sense, as I watch the presenters click buttons and choose menu selections, that I do not have on display and or available. Functionality is having a backward and confusing effect on the mass of tutorials available for Unity, they are like an MOT, only good the date of issue.
     
  12. path14

    path14

    Joined:
    Apr 9, 2017
    Posts:
    113
    If you're an artist as I am / was, then I recommend all the beginner tutorials before anything else if you're planning on working on a game independently. Also, I suggest learning the basics of programming / coding before jumping into creating a game in Unity and / or to conclusions about the integrity of Unity. It's not a perfect program (which program is?), but it's incredibly powerful and it definitely takes time to learn. More than a year later and I still haven't touched all the features :p
     
  13. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    I have to turn off then on all primitive colliders instantiated in runtime now since I upgraded to 2018.2.2 or they won't interact with anything. Pretty horrible.
     
    path14 likes this.
  14. A_World_Maker

    A_World_Maker

    Joined:
    Apr 21, 2018
    Posts:
    214
    I have used many platforms for my numerous scenes, and never once did I need to code anything. There is a lack of basic assets available, including shipped scripts. I went through ALL of the beginner tutorial videos, but as I said previously they do little to teach as most of the UI menus and selections are either changed location, name or removed.

    A for instance, I have created a couple of particles using NG tools, on my third particle I discovered I could not change the material used, unless I purchase the full version..... surely a basic particle system, which is all I need, is part of the system? Whats worse, I cannot seem to uninstall any tools once installed.

    Anyway, back to my post regarding mesh colliders, I overcame the issue by adding a component to the mesh in the hierarchy list, once I had selected the mesh, then went to the inspector, a mesh collider, which mimics the mesh exactly. Also adding a RigidBody component gave it mass so I don't fall through.
    There are no tutorials for this, I gleaned it from watching lots of other tutorials on Youtube, then put the information together by compiling the different elements by trail and error. It seems no one would use a mesh as a terrain, whereas I like land bridges, caves and overhangs etc in my terrains.
     
  15. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    Something specific you're having trouble with andrew?
    There is no "full" version of Unity anymore, they stopped doing that about a year ago. The free version has everything in it except for some team management and analytics stuff. You can certainly change the material used by particles. For mesh colliders to interact with other mesh colliders there are certain rules listed in the documentation:
    https://docs.unity3d.com/Manual/class-MeshCollider.html
    You're player shouldn't be using a mesh collider though. "so I don't fall through"? You also need to use continuous collision detection (on the player, usually a capsule collider) to safely traverse mesh colliders at high speeds or you risk falling through them. Terrain colliders have thickness, I don't think you can give that to meshes, though I would love to =D

    you can delete/uninstall packages freely as well.
     
  16. A_World_Maker

    A_World_Maker

    Joined:
    Apr 21, 2018
    Posts:
    214
    Hi Guys,

    Like always, I use things until I break them, it's the only true method of learning, to know the limitations first. For my terrains I use a mesh collider. 'Normally' I would make a collision mesh of my own, based upon LOD/polygon density Zones, areas that are 'playable' I use quality collisions. ln areas that the player may wander, the low quality mesh areas and of course, where the player cannot go, no collision at all.

    Using a mesh collider in Unity is less efficient as it applies collision to the whole mesh. If I import my collision mesh and apply a mesh collider to that, all I have to do is align it with the 'decorative mesh' and turn off render. I a lot of platforms, the importer will do that automatically by declaring the collision mesh at that point. Of course, if you have not made, or have the need to make a collision mesh, you can simply use the original mesh for collision as well.

    The backward compatibility issues with upgrading Unity is perhaps a bit more of a concern. Scripts being the first to mind, what worked today may not work tomorrow. I suppose the lesson is to stick with the same version per project. I would not like to be someone trying to sell their skills for scripting on the Unity Store, given the limitations of which version it will work for. I see a lot of video tutorials on YouTube scripting in JavaScript as opposed to C#, are the scripts still viable?
     
  17. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    Found out I have to turn off and on my terrain colliders if I want to raycast against them the first frame they are active now too =[ seems to work after the system LODs them at least once anyway, but I needed an immediate raycast for a specific function. I'll have to try 2018.3b tomorrow if I can remember to.
     
  18. malkere

    malkere

    Joined:
    Dec 6, 2013
    Posts:
    1,212
    Seems to be working in 2018.3b
     
    path14 likes this.
  19. ristophonics

    ristophonics

    Joined:
    May 23, 2014
    Posts:
    32
    Seem to have to same problem in 2018.4.0f1. I upgraded a project from Unity 5.6.6 and everything is working fine. The runtime colliders have the right parent, layer, and settings but NOTHING. no OnTriggerEnter... I'm going to try the ON/OFF?ON method after start
     
  20. Marcpp2018

    Marcpp2018

    Joined:
    Apr 24, 2017
    Posts:
    1
    listen all i resolve this at last for now, if you instantiate and want contact by name dont work , past it by tag ! this way works for me.


    //--------------------------------------------
    work:

    private void OnTriggerEnter2D(Collider2D col)
    {
    if (col.gameObject.tag == name)
    {
    contact = true;

    }
    }


    //---------------------------------------------------------//
    dont work!!:


    private void OnTriggerEnter2D(Collider2D col)
    {
    if (col.gameObject.name == name)
    {
    contact = true;

    }
    }

    i dont know why dont work , after instantiate dont Triggerenter
    remember this is for a 2d game rules.
     
  21. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,423
    You're posting on an old thread that has nothing to do with your post. The main thread is also about 3D physics not 2D physics. Please create your own thread, thanks.

    Also, please use CodeTags when posting code.
     
    malkere likes this.