Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Collision has no contacts?

Discussion in 'Physics' started by Exonto, Apr 4, 2018.

  1. Exonto

    Exonto

    Joined:
    Nov 22, 2017
    Posts:
    16
    For some reason (and I've looked around for answers to this), the collision I receive with OnCollisionEnter does not always have any contact points. Once every 20ish collisions or so the array will simply be empty. I've had to check every single time whether the contacts array length is equal to zero to prevent out of range errors. How is this possible?
     
    ThisGamesTooCool likes this.
  2. ThisGamesTooCool

    ThisGamesTooCool

    Joined:
    Apr 5, 2018
    Posts:
    28
    I don't work very commonly with this collision enter events, so I don't know why this can happen... here is a possible solution:
    Code (CSharp):
    1. if (myArray <= 0)
    2.     return;
    I hope it can be usefull for you!
    PS: Sorry for my bad english...
     
  3. Exonto

    Exonto

    Joined:
    Nov 22, 2017
    Posts:
    16
    Yea that's what I'm currently doing. I'm just worried that this will have consequences because I'm essentially ignoring a collision.
     
  4. GregoryFenn

    GregoryFenn

    Joined:
    Feb 13, 2018
    Posts:
    43
    That sounds like a strange bug... are there any gaps in the mesh of eithe collider perhaps? I can't think why else there would be a "collision" but no collision points.
     
  5. ThisGamesTooCool

    ThisGamesTooCool

    Joined:
    Apr 5, 2018
    Posts:
    28
    If you can administrate good the code and you know what every part of your script does you don't have to get errors.
    Unity has got a LOT of this funky bugs, and usually this kind of solutions are the unique what works...
    You can ask to a developer of Unity and see what he says. Sorry but I can't do a lot more here...
    I hope I be helpfull!