Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Collision is not detected on device? Wtf?

Discussion in 'Physics' started by sam268, May 1, 2015.

  1. sam268

    sam268

    Joined:
    Apr 21, 2014
    Posts:
    149
    Title says it all. Made a simple onTrigger script, did everything right, like I have done it a thousand times before.....

    The collision worked fine on the game view in unity, so I uploaded it to my android, but it does not work on android? What is this? The collision is detected fine on my pc but not on my android? Why is this!? It is driving me nuts!
     
  2. cl9-2

    cl9-2

    Joined:
    May 31, 2013
    Posts:
    417
    Is this a box collider trigger?
     
  3. sam268

    sam268

    Joined:
    Apr 21, 2014
    Posts:
    149
    Ok, maybe I should explain the whole thing better, so you can better understand what I'm trying to do here.

    I want to create a door, and when you look at the door, a button appears and if you tap it it takes you "outside" or to the next scene. I have a long, thin, trigger capsule collider that points wherever the player looks (it's attached to the main camera) . This is called the player manager. It has a rigidbody attached for onTrigger events. I use it to pick up objects, open doors, activate things the player is looking at, etc.

    Now I have a door. Its just a cube with a door texture I found on google images lol. It also has an onTrigger collider, but no rigidbody. I have a simple one line script on my door (its literally just a single public variable). The script basically says what scene the door goes to.

    So, I made a script for the player manager. It basically says that onTriggerEnter, if other tag == door than a button appears. When you click the button it takes you to the new scene. The script is very simple, and works ABSOLUTELY FINE in the editor. I press play, and look at the door, and the button appears, I click it, and boom, next scene.

    But for some reason unbeknownst to me the script does not work on my actual android. Its like the collision isnt detected on my device or something. It is very bizarre, and I have tried almost everything, and cannot figure out why it isn't working. These forums are my last resort lol

    P.S. just for a test, I scratched the whole button thing, and made it so that the scene automatically changes when the collision is detected. Once again, worked fine in editor, but not on my android. So my android is deffinately not even detecting the collision.
     
    Last edited: May 1, 2015
  4. cl9-2

    cl9-2

    Joined:
    May 31, 2013
    Posts:
    417
    What would happen if you were to replace the capsule collider trigger with a box trigger of similar dimensions?
     
  5. sam268

    sam268

    Joined:
    Apr 21, 2014
    Posts:
    149
    Makes no difference, its the same exact thing with a different shape, isn't it? I tried every type of collider...

    Well anyways it didnt work :/

    My biggest issue is understanding what could possibly cause something to not work on my android that works fine in the editor.
     
  6. cl9-2

    cl9-2

    Joined:
    May 31, 2013
    Posts:
    417
    It's possible that the Android implementation of either PhysX or the Unity Physics wrapper has a bug.

    Does everything work on an actual PC build? Or with WebPlayer or WebGL?
     
  7. sam268

    sam268

    Joined:
    Apr 21, 2014
    Posts:
    149
    Well, i click play in the editor, and everything works fine. but on android it does not.
     
  8. sam268

    sam268

    Joined:
    Apr 21, 2014
    Posts:
    149
    oh, btw, I just got unity 5, is this a unity 5 bug? because this never happened on unity 4
     
  9. sam268

    sam268

    Joined:
    Apr 21, 2014
    Posts:
    149
    Could I possibly fix this issue by reinstalling Unity 5? This wouldnt mess up my save files would it?
     
  10. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    cl.9 was suggesting doing a pc build to test (not run in editor).

    re-installing unity is unlikely to solve the problem.
     
  11. thienohs

    thienohs

    Joined:
    Feb 6, 2014
    Posts:
    13
    I have the same problems on iOS devices. But the bad thing is it is happening occasionally.
    So basically, on average, If I run the game 3 times on an iPhone, 1 out of the 3s : none of the colliders are working, no trigger entered, no colliding (raycast is still fine).

    And I always get these WARNING in XCode :

    Multiple managers are loaded of type: PlayerSettings
    (Filename: Line: 276)
    Multiple managers are loaded of type: TagManager
    (Filename: Line: 276)
    Multiple managers are loaded of type: PhysicsManager
    (Filename: Line: 276)
    Multiple managers are loaded of type: QualitySettings
    (Filename: Line: 276)
    Multiple managers are loaded of type: Physics2DSettings


    Did anyone come up with a solution ? Is it a bug or a setting issue ? It seems to be a very serious issue.
     
  12. cl9-2

    cl9-2

    Joined:
    May 31, 2013
    Posts:
    417
    Yes.

    Also, I've messaged @MortenSkaaning regarding problems with triggers and colliders not working properly on iOS and Android.
     
  13. MortenSkaaning

    MortenSkaaning

    Joined:
    Jan 16, 2015
    Posts:
    120
    Hi,

    Can I get you to submit a bug report with a repro case for this? Then it's easier to test across multiple devices.

    Thanks
     
  14. thienohs

    thienohs

    Joined:
    Feb 6, 2014
    Posts:
    13
    Hi Morten,

    I assume you are asking both me and sam. My scene is quite big but I'll try to simplify it and will submit a bug report.

    At the moment, It looks like I run into another issue which I can't reproduce the problem because the XCode keep crashing on me on the error Could not produce class with ID 159 (Screenshot). I've done nothing different from the last message that could cause this except deleting some objects from the scene and straight to build to XCode. Looks like Unity 5 is a very random guy :)
     

    Attached Files:

  15. MortenSkaaning

    MortenSkaaning

    Joined:
    Jan 16, 2015
    Posts:
    120
    We'd love to get a bug report on the "Could not produce class with ID 159" problem as well.
     
  16. thienohs

    thienohs

    Joined:
    Feb 6, 2014
    Posts:
    13
    Actually, I found the issue is caused by this plugin : https://www.assetstore.unity3d.com/en/#!/content/26181
    It created an invisible game object (somehow it's so invisible that I don't know how to make it visible) that refer to EditorSettings.
     
  17. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    I'm also receiving the "Multiple managers are loaded of type: PlayerSettings" error from when I installed that plugin.
    I'll try to dig more on this, and I'll point the developer to this task.
     
  18. sam268

    sam268

    Joined:
    Apr 21, 2014
    Posts:
    149
    Well, seeing as this seems to be more of a bug then human error (which is what I was hoping for) and it is currently somewhat unfixable, is there any way to detect objects without onTrigger collisions?

    p.s. I am also getting lots of weird, random error messages in the editor that I have never seen before, but they are very random when they appear, so I can't really recreate the error. I will copy/paste it here when I see them again though.
     
  19. sam268

    sam268

    Joined:
    Apr 21, 2014
    Posts:
    149
    Ok, here is the error I get like every 30 minutes when the editor is open.

    <RI.Hid> Failed to create device file:
    2 The system cannot find the file specified.



    Does this mean anything? I have never seen it before until recently, same time onTrigger collisions stopped working.
     
  20. d-navarro

    d-navarro

    Joined:
    Apr 27, 2013
    Posts:
    75
    Hi, I'm the author of Inspector Navigator, and I wanted to say I'm working on fixing some of these problems (there's a lot of weird stuff mentioned on this thread, and I'm sure that not everything is related to Inspector Navigator ;)

    However it seems that the object I create to keep the inspector breadcrumbs can point to many objects like the project settings stuff, and this can cause problems in some builds.

    Because of that, I hope to release in a couple of days a new update to address the source of these issues:

    - Using Unity5's HideFlags.DontSaveInBuild the breadcrumbs will no longer be included on builds
    - For Unity4.x I'm adding an option to remove all the breadcrumbs from all project scenes, so it can be used before a build.
    - ProjectSettings objects (those mentioned in the 'Multiple managers are loaded' errors) will now be filtered (not included in the inspector breadcrumbs) - I don't know why these problems show now, why this objects are not singletons (preventing multiple instances), or why a reference to the object is causing unity to instance more copies of them, but hey! :-/
    - And many other small fixes that will hopefully help getting rid of these issues.

    Anyone experiencing problems with Inspector Navigator, please email contact@wasabimole.com

    Thank you!
     
    Bakanovskiy95, thienohs and mcmorry like this.
  21. sam268

    sam268

    Joined:
    Apr 21, 2014
    Posts:
    149
    YES thank you, this is what I wanted to hear ^^^^^ :)

    But honestly, I really hope this fixes the issue, thank you so much for taking our issues into consideration d.navarro!
     
    d-navarro likes this.
  22. d-navarro

    d-navarro

    Joined:
    Apr 27, 2013
    Posts:
    75
    I just submitted Inspector Navigator's version 1.20, that will hopefully help alleviate some of this stuff.

    1.20 Strip breadcrumbs update
    - InspectorBreadcrumbs no longer included in build on Unity 5 (using new HideFlags.DontSaveInBuild)
    - New menu option to delete inspector breadcrumbs from all project scenes (so they can be removed before performing a build on Unity 4.X)
    - InspectorBreadcrumbs are no longer created again right after being deleted (only after a new object/asset selection)
    - Do not create InspectorBreadcrumbs when selecting any filtered object
    - Upon load scene, do not automatically center camera on last selected object
    - New Scripts & TextAssets filter type, disabled by default
    - New ProjectSettings filter type, disabled by default
    - Removed all filtered objects from breadcrumbs on load scene
    - Modifying object filters has now immediate effect
    - InspectorBreadcrumbs object is now filtered, and no longer appears in the breadcrumbs bar
    - Warning before enabling project settings tracking on Unity 4.X
    - New menu option to check for new user notifications
    - Other small bug fixes

    This version will be available to download as soon as it goes through Asset Store review.
     
    mcmorry and sam268 like this.
  23. sam268

    sam268

    Joined:
    Apr 21, 2014
    Posts:
    149
    Awesome, this will hopefully fix existing projects, yes? Can't wait for the update!
     
  24. d-navarro

    d-navarro

    Joined:
    Apr 27, 2013
    Posts:
    75
    Yes, it's been built to fix existing projects (removing the breadcrumbs from builds, and references to problematic objects). For Unity 5 projects, it should do it automatically once you load and save a scene. But in any case, I recommend to use the new menu option "Clear breadcrumbs from all project scenes" once, to make sure you remove all scene references to these problematic ProjectSettings objects (from this point, new inspector breadcrumbs objects will be tagged "DontSaveInBuild", and should no longer cause any trouble).

    For Unity 4, pretty much the same, you should use the option once, and because now the ProjectSettings objects are filtered, there should be no more problems. But if anyone wanted to remove the breadcrumbs from scenes in a final build in Unity 4.X, they could use the same "Clear ..." menu option just before performing the build (this is because the DontSaveInBuild flag is only available on Unity 5).
     
    sam268 likes this.
  25. sam268

    sam268

    Joined:
    Apr 21, 2014
    Posts:
    149
    Hmm, I can't find the "Clear breadcrumbs from all project scenes" anywhere in Unity 5, but I am assuming that I have the update installed. Hopefully this fixes my issues, I'll get back later today.
     
  26. d-navarro

    d-navarro

    Joined:
    Apr 27, 2013
    Posts:
    75
    I'm sorry Sam, the update 1.20 is still pending review, and isn't on the Asset Store yet. Please email d.navarro@hotmail.es if you need it now.
     
    sam268 likes this.
  27. sam268

    sam268

    Joined:
    Apr 21, 2014
    Posts:
    149
    Ahh ok thats fine I can wait :)
     
    d-navarro likes this.
  28. d-navarro

    d-navarro

    Joined:
    Apr 27, 2013
    Posts:
    75
    Inspector Navigator version 1.20 - Strip breadcrumbs update - is now available on the Asset Store. Remember to select the new menu option "Clear breadcrumbs from all project scenes" (might take a while if you have many big scenes), and you should then be fine in all future builds (regarding this "multiple managers loaded" issue that seemingly led to some of the problems mentioned in this thread).

    If you have any further questions/issues with this new update, please email me. Thanks!
     
  29. d-navarro

    d-navarro

    Joined:
    Apr 27, 2013
    Posts:
    75
    Disable inspector breadcrumbs serialization with Inspector Navigator 1.22

    You can now disable saving the Inspector Navigator state (object breadcrumbs) in a scene object, if you do the state will remain only in memory during a Unity session.

    1.22 Disable serialization update
    - Serialization of breadcrumbs on scenes can now be disabled
    - Dialog for clearing project scenes when checking serialization off
    - Optimized tool start-up times when opening up a scene
    - Fixed problem where breadcrumbs disappeared when going into play mode
    - Unselecting an object no longer marks the scene as changed
    - Changed default object queue length to 64
    - Other small bug fixes

    Asset Store link: http://u3d.as/awA

    Note: If your current version is 1.14 or lower, please read the 1.15 update warning (you can check your version number in the Help and Options dialog).
     
  30. Veerababu.g

    Veerababu.g

    Joined:
    Oct 8, 2015
    Posts:
    2
    i too had this issue(collision is working on my pc but not for android device) .is it solved .if so then suggest to me also.
     
  31. crash664

    crash664

    Joined:
    Nov 22, 2012
    Posts:
    91
    Hi there,

    I'm having the same problem just now. The collision detection works fine in the editor, but when sent to my Android device, the collision detection behaves very erratically (if at all). I didn't see how the breadcrumbs talk above solves this problem? Did I miss something? I'm using the cardboard SDK for VR on Android.

    Thanks
     
  32. M329

    M329

    Joined:
    Jan 5, 2016
    Posts:
    1
    i have the same question.
    The collision worked fine on the game view in unity, but it does not work on android and ios.

    if u find the way to fix it, plz tell me, thanks
     
  33. crash664

    crash664

    Joined:
    Nov 22, 2012
    Posts:
    91
    By the looks of it, it's a platform bug :(

    I managed to make a workaround for my application so far because I was only using box colliders as a boundary for some objects, so I just coded the ranges and manually called my actions. I hope this doesn't affect ray-casting however, or I'm in big trouble :(
     
  34. jimjames

    jimjames

    Joined:
    Nov 23, 2013
    Posts:
    63
    Has anyone solved this yet? I am experiencing the same problem. App works fine in unity editor run time, but once I build, install, and run the app on my android there seems to be no trigger/collision detection.

    EDIT: alittle more testing made me discover that for some reason my tags got deleted. I still saw my tags in the drop down but when i clicked add. The list was empty. I redid all my tags and build, installed, and ran app on my android and all the collision worked. Hope this helps someone.
     
    Last edited: Feb 12, 2016
  35. saybor

    saybor

    Joined:
    Jan 29, 2015
    Posts:
    5
    Same problem here.
    Collision detection working perfect in Editor or PC build.
    When launching on Android device - even Raycast cannot found ground.
    I'm not using tag checking, etc.

    P.S. Tested on version 5.2 and 5.3. Same
    On previous version unity 4 - everything works perfect.

    Have no idea what to do.
    Nothing changed in the code, only change - is using new version of Unity.
    All collisions don't work - raycast, character controller fall through floor, etc.

    Any ideas?
     
    Last edited: Feb 20, 2016
  36. saybor

    saybor

    Joined:
    Jan 29, 2015
    Posts:
    5
    Issue with collisions solved in version beta version Unity 5.3.2p4.
    Thanks :) Hope it will not be broken again in 5.4 :)
     
  37. amidofu

    amidofu

    Joined:
    Mar 1, 2016
    Posts:
    23
    I have the same issue on 5.3.3f1, but works fine on 4.6.1
     
  38. amidofu

    amidofu

    Joined:
    Mar 1, 2016
    Posts:
    23
  39. 1Riptide

    1Riptide

    Joined:
    Jan 10, 2016
    Posts:
    4
    Same here. My problem was that I exported a scene into a new project and in the new project, apparently the Tags were missing. Hard to catch because collision detection still worked fine in the editor as though the Tags were there.
     
  40. shanzebali

    shanzebali

    Joined:
    Aug 18, 2015
    Posts:
    4
    I am facing the same problem, Game works fine on unity editor but doesn't detect collision on android.
     
  41. Tom_Timothy

    Tom_Timothy

    Joined:
    Nov 21, 2013
    Posts:
    132
    Yes I also am Having this problem at random is there any fix?
     
  42. araz01

    araz01

    Joined:
    Aug 2, 2016
    Posts:
    53
    i know why!! you need to tap the particle to make it work!! lol i just figured it out.... just found the issue too lol, i believe adding it to the root i guess would fix it.. im new soo :D . tap twice, i might be wrong lol i think i forgot to include the stuff in the touch location rather then... umm mouse down but still works like i said lete me sees
     
  43. shafayat18

    shafayat18

    Joined:
    Nov 9, 2016
    Posts:
    3
    i was face similar problem but i was solved it.
    :::::: How ::::
    Some of time When build game for android apk..
    coding compress/minify::
    for this reason all coding get 1 or 2 lines.

    if you use single line comments " // " in c# script
    coding also modify by comments for compressing..

    so delete all single line comments // or use multiple line comments /* your comments */
     
  44. ukUnityVrUser

    ukUnityVrUser

    Joined:
    Dec 10, 2015
    Posts:
    11
    Same issue here on both iOS and Android. Might remove my tags and do collision detection based on names instead?
     
  45. URGr8

    URGr8

    Joined:
    Sep 10, 2012
    Posts:
    23
    Well I spent many hours trying to figure this out and thought it was my code, but it turns out that Unity is reporting the wrong Tag with OnTrigger events. Seems like it's giving me the Tag one up in the project settings from what the Gameobject has it assigned to. (i.e Tag 3 instead of Tag 2). It works fine in the Editor, but not on the IOS device, and some people say Android.
    This is with Unity 5.61.p1. I had upgraded from 5.3.

    So not sure where the problem came from but there is one working solution that I know of.

    It seems that there is still a bug in Unity with Tags. If your project has (Removed) tags. (The unity project claims it will remove them when the project is next loaded, but it doesn't.) If you build it for the device, it will remove them and move them all down, so it confuses things.

    tldr;
    The way to FIX THIS is to add a fake Tag like "Something" and then reload the project, the removed ones will be gone and it will work. Tested it on the device. Hope this helps someone.
    Here is the reference to the issue:
    https://issuetracker.unity3d.com/issues/unable-to-edit-or-delete-tags-in-editor?page=1#comments
     
    SidRed and Cskirt like this.
  46. Multiplayer

    Multiplayer

    Joined:
    Dec 29, 2012
    Posts:
    15
    This may or may not be the same issue I replied to here: https://forum.unity3d.com/threads/script-not-working-in-build-ok-in-editor.40806/#post-3140643

    If it is, there is another solution:

    Open "ProjectSettings / TagManager.asset" with a text editor. There will be a list of tags, like so:

    tags:
    -
    - Wall
    - Rail
    - Blast
    - Sphere
    ...​

    If your list includes empty lines (like the first one in my example), delete them to fix all your problems. They are leftovers from tags that you once deleted, but Unity never completely removed them from the list. Apparently all Unity builds prior to 5.5 were able to deal with these nameless tags, which is why I had to go through years of my file history to find out how this problem started :)

    This may be useful for anyone where the create-a-tag method does not work.
     
    Deleted User, Sailendu and Cskirt like this.
  47. Trend86

    Trend86

    Joined:
    Jul 25, 2019
    Posts:
    7
    Having the same problem in 2019.3.3
     
  48. hamza37

    hamza37

    Joined:
    Feb 5, 2017
    Posts:
    10
    having the same problem with unity 2019.2.17.........any solution?
     
  49. starjabudigitalltd

    starjabudigitalltd

    Joined:
    Dec 14, 2018
    Posts:
    1
    Just upgraded to 2019.3 and got this issue, has anybody figured out a possible solution?
     
  50. wolfomat

    wolfomat

    Joined:
    Oct 19, 2014
    Posts:
    24
    i have a similar issue.
    but this time it is more that i have 4 box colliders as triggers.
    while on PC / Editor the collider 0 - 3 are working fine, it seems that the colliders a shifed to the left.
    which means, that collider 0 triggers like it was collider 3 ,1 triggers like it was collider 1, 2 triggers like it was collider 3, 3 triggers like it was collider 0.....