Search Unity

Collision Detection completely fails

Discussion in 'Physics' started by Homicide, Feb 13, 2019.

  1. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    657
    I don't understand, you can clearly see the colliders all intersect. Yet if i stand still beside the object, the TriggerStay event just stops working. I use a simple debug log message to observe this.

    If i move at all , they detect each other fine, but not if i stand still. I really don't see what the issue is here other than its broken completely.

    Theres no elaborate code, nothing, its really simple, yet...

    Code (CSharp):
    1.     private void OnTriggerStay2D(Collider2D collision)
    2.     {
    3.         if (collision.gameObject.CompareTag("Player"))
    4.         {
    5.             Debug.Log(gameObject.name + " : is colliding with " + collision.gameObject.name);
    6.            


     
    Last edited: Feb 13, 2019
  2. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    657
    Tested over and over, and the result is, the collision detection works ONLY if one of the objects is moving. That defies the entire logic to OnTriggerStay doesnt it?

    It seems kind of useless if it can only detect a moving object, or if it is moving itself.
     
    Last edited: Feb 14, 2019
  3. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    657
    Hmm , i may have solved this. It appears as if rigid bodies are set to sleep within .5 seconds... seems really ridiculous at such a low value, the player can not possibly stay active.

    So, my next question is then... is there a way to change the sleep value of only ONE rigidbody? I can only locate the physics general setting which appears to change ALL rigidbodies.

    EDIT : NVM, found it.