PolygonCollider2D issues

Hello everyone,

Three days ago, I encounter an unprecedented issue during the development of one of my game, which I’ve described here : Editor/Game random crash at Scene launch - Questions & Answers - Unity Discussions
For the tl;dr people, it’s an issue which made my Editor/Game crash randomly during the Application.LoadLevel of a scene.

After 3 days of struggle, I’ve finally found something interesting, and I thought I should share it here to found some answers, and if it’s not the case, maybe flag a bug in Unity 2D engine.

So, after bug which I told upper in the post, I’ve tried to put all my GameObject in files and load it directly from there (and not clone them from the already instantiate versions) and I discover than my issue was in fact than the objects, when they’re instantiated with that

GameObject obj = (GameObject) Instantiate(g,startPos,Quaternion.identity);

are, sometimes, without any reasons, created in the place (0,0,0) and have a PolygonCollider2D infinite (or of the size of the scene) and is triggered.

In my case, it’s an obstacle which spawn and move, and should hit the player which trigger the “Game Over”.

In my first case, it triggered the “GameOver” action, which apparently makes the games/editor crashes (maybe because all the objects try to active the trigger at the same time, or maybe because a game over before the start of the game is not a case handle by my code, probably).
In my new case (with the objects created during the game), it triggers a “no reason” gameover (we hit the obstacle but there is no obstacle on screen because at the moment of the hit, it’s on (0,0,0)).

It happens like 9/10 launchs on the Android build, and something like 1/100 launch on PC.
And the only reason I know there are instantiate in (0,0,0) it’s because I was able to get that from the logcat :

Imgur

As comparison, this is a “normal hit position”.

Imgur

I have to say, it happens with all my obstacle (they are determined randomly but I found in the log a bug with all of them).
At first, I thought it was because I had this warning

but I re-sized all my game to fix them, but the bug is still here.

I don’t want to use “classical hitboxes” (like squares and circles) but I can’t figurate out how I can fix this bug.

I’m pretty desperate, it’s the first time I encounter a bug this large and this critical, I hope this is my fault, somewhere, and I just didn’t see where x).

Note : I don’t want to distribute too much code here because it’s some kind of professional work here, but if you need specific ones to verify stuff, just ask, I’ll be happy to share the most of it.

Okay, my bad, it was an Unity issue fixed at the 5.1.3 (mine was 5.1.1, didn’t notice I was late).