Search Unity

Collision not working on Android

Discussion in 'Physics' started by strongbox3d, Sep 22, 2018.

  1. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Hello guys,

    I am having this problem where collision works perfectly inside Unity(Unity 2018.2) but when I run the game in Android(so far), it works well, but then suddenly stops working. Anyone has any idea of what the reason for this could be?

    I have spent one week googling this problem, and all I find is old posts without solutions although many people have encountered this problem even in iOS.

    Any help would be very much appreciated.

    Regards,
    Carlos
     
  2. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    So, not even a replay telling me that I am stupid!? Seriously? What happened with the forums? people used to answer in the old times... I know for a fact that many other people are experiencing this same issue, but there isn't any answer all over the internet yet.

    Any help? Please?
     
  3. Marcos-Schultz

    Marcos-Schultz

    Joined:
    Feb 24, 2014
    Posts:
    381
    To help, we need more information.

    What type of collider are you using?
    How many FPS the game is running on mobile?
    Does the problem happen if you compile the game for windows?
    Can you post some prints?
     
  4. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Great! thank you man for answering.

    I use CharacterCollider for the player, it is running very smooth at 30 fps, I don't know about windows because I haven't done any windows build since my game is for Android/iOS. There isn't any prints, not errors, not warnings, that is one of the reasons the issue is so difficult to understand.

    I know that I can't reproduce the issue in the editor, and everything works perfect when running the game in the editor. Once I run it on the device, collision works only the first time the player collide with something in the game, after that, the character goes through all the rocks, plane(ground) which is not unity terrain just a plane mesh, the fish goes through rocks as well, my reticle for aiming which it should turn red when it is over a fish, doesn't turn red anymore(I am using a ray from the center of the screen into the world for this).

    If you have any other question I will be happy to answer, because I have spent more than a week, trying to solve this issue without any luck.

    Regards,
    Carlos
     
  5. Marcos-Schultz

    Marcos-Schultz

    Joined:
    Feb 24, 2014
    Posts:
    381
    Hello. Is it possible for you to mount a small scene where the problem occurs and post here so we can test?

    Maybe with access to the scene with the bug I can detect where the problem is.
     
  6. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    I don't really know how to do that, since the problem is in all the scenes of the game and game is completely done. The only thing stopping me from published to the Google store is this bug. Also the bug only happens when the game is on the device, it is not possible to recreate the bug in the Editor where everything works perfectly not matter what I do while playing it in the editor.

    I could send you the APK with only the first scene perhaps? but then again with just the apk you will only see the collision not working after the first few collisions of the player with any part of the environment.

    I can try to reduce the game to one scene only, but you would have to create an apk and test it in a device in order to see the collision issue. Can you do that?

    Please let me know, I have not too much left hair in my head to pull!

    Regards,
    Carlos
     
  7. strongbox3d

    strongbox3d

    Joined:
    May 8, 2012
    Posts:
    860
    Ok I finally found the reason for the issue with collision in Android! Now that doesn't mean that I fixed it, just that I found it and it is pretty weird. Anyway the issue was created by "Cinemachine Collider" in the MainCamera. As soon as I removed the component from the camera, everything is works perfectly on the device, all the collisions work, raycast, and what not.

    Since I found the problem and it is specifically related to cinemachine, I am heading to the Cinemachine forum to start a conversation about this issue.

    Regards,
    Carlos
     
    Jiu_Jitsu likes this.