Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question Rigidbody issue, ball stay stuck in board when immobile

Discussion in 'Editor & General Support' started by hbollon, Apr 27, 2020.

  1. hbollon

    hbollon

    Joined:
    Apr 27, 2020
    Posts:
    6
    Hello !
    I'm working on a 3d maze game project on Android controlled by gyroscope.
    I encounter a problem, my ball move perfectly but when I immobilize it a moment (in a corner for exemple but it can happen everywhere) it stay stuck...
    I have :
    1. a board (his mesh is .obj imported from blender, mesh config on first screen) with mesh collider (also tried with box collider) -> config on second screen
    2. a ball with sphere collider and rigidbody -> config on third screen
    A preview of the issue :


    It's very weird, because if I keep moving the ball it work very well...

    You can find my project on : https://github.com/hbollon/LabyrinthEvolved/tree/physics

    Thanks in advance !
     

    Attached Files:

  2. DiegoDePalacio

    DiegoDePalacio

    Unity Technologies

    Joined:
    Oct 28, 2009
    Posts:
    508
    Hello @hbollon,

    From the video that you posted, it looks like there is something on your code that under certain conditions an error occurs, and then the ball position is not updated anymore.

    My recommendation is to debug your mobile game, using a USB connection with your computer, checking the logs, where more likely you'll be able to find the actual error.

    You can find more information about how you can do it here: https://docs.unity3d.com/Manual/ManagedCodeDebugging.html


    Happy Coding!
     
  3. hbollon

    hbollon

    Joined:
    Apr 27, 2020
    Posts:
    6
    Hi @DiegoDePalacio !
    Thanks for your reply.
    I have already checked with logcat and I haven't saw any error/warning when the bug appear...
    But I will retry with your link ;)

    However, for the moment I don't have any script on the ball
     
  4. hbollon

    hbollon

    Joined:
    Apr 27, 2020
    Posts:
    6
    Ok so I have try to look at debug console in vscode and retry with logcat and I haven't any error or exception...
    I also tried without my board scripts without success.
    However, I test now on unity editor with Unity Remote 5 for the gyro and I have noticed than when the ball stop moving (when it's immobile few seconds) I can fix it by reset his rigidbody or manually moving it but it happens again if it is still immobile

    EDIT : I'm on Linux (Ubuntu 18.04) if it can help someone
     
    Last edited: Apr 28, 2020
  5. hbollon

    hbollon

    Joined:
    Apr 27, 2020
    Posts:
    6
  6. hbollon

    hbollon

    Joined:
    Apr 27, 2020
    Posts:
    6
    Ok so I have finally found the reason of this issue
    The rigidbody of the ball falls asleep when immobile and wait for physic interraction to awake but my board don't have rigidbody.
    So I have disable it with :

    Code (CSharp):
    1. m_Rigidbody = GetComponent<Rigidbody>();
    2. m_Rigidbody.sleepThreshold = 0.0f;
    I think you can also just awake it manually in Update method for exemple but in my case I don't need at all of this sleep function for my ball.
     
    DiegoDePalacio likes this.