- Home /
Graphic anomalies and loss of physics with Unity 3.5.6 + NGUI + TK2D
Hi there,
So my company has been developing a product for android that in many ways mimics an iso-deco style game. It's visually 2D. Players can scroll the cam left / right, zoom in / out, buy buildings, place buildings, move buildings, upgrade buildings, interact with NPCs (tap interaction), etc... etc...
Very recently we were hit with a bug that we have not been able to resolve or even isolate to a particular area of the game. The bug is that after a non standard amount of time our game objects will appear to start z-fighting and lose box-collider response to a raycast, i.e. no physics / tap response.
We've tried camera proximity to 0, we've tried ortho with alpha test shaders, we've tried render queues, we've tried removing individual aspects of our game (npcs, buildings, UI, backgrounds, etc...) one at a time, we've tried multiple cameras with individual layers, we've tried reducing the size of our textures, we've tried forcing to a 24bit buffer, we've tried enabling / disabling static / dynamic batching, we've tried forward and deferred rendering (currently using vertex lit), etc... Always we will eventually lose input and there will be graphic anomalies / apparent z-fighting.
I've looked at our main camera's projection matric, forward, right and up vectors, positions in world and local, fov, size, etc... before and after the bug with no discernible difference.
I've run a dev build and looked at it in Eclipse with the DDMS and our memory footprint does not seem to be drastically different before or after the bug occurs.
I create a runtime boundingbox with GL.Draw to show the box collider in game and it is always where I expect it to be.
What really messes with my mind is how before the bug occurs I can cast a ray with every tap and list the objects it collides with, everything is as expected. After the bug, though everything looks to be in the same location, Buildings, npcs, etc... (minus the z-fighting) the ray cast will come back and list 0 collisions.
we are running unity 3.5.6 Pro 2/ android (but have tried with 3.5.7) the latest NGUI and the latest 2dToolkit.
Please, any advice would be very very appreciated.
Answer by FHRaph · Dec 28, 2012 at 04:42 AM
So this turned out to be a divide by zer0 error. It seems, though we have not determined exactly where in out code base, one of our return values from a call to a static class was returning a value that was either zero or in calculable. This then caused our camera to treat our objects as though they were at nan, infinity, or -infinity on scale-z.
I wish I could be more specific about which call it was or in relation to what object, component, 3rd party software, etc... but I cannot. One of our guys took it upon himself to track down every potential divide by zer0 case and do the appropriate checks. After those checks were in, the problem was resolved.
Your answer
Follow this Question
Related Questions
GetPixel() returns only one value 2 Answers
Grass is very high 1 Answer
Colliding 2 completely flat quads with physics? 5 Answers
Game build works fine in Android but is jittery in iPhone. 0 Answers
Countdown little help...! 1 Answer