Build Problems!

So i made a game that tries out various types of AI in unity. I made an AI that follows the player and rotates towards the player. The code is fine and everything works as expected. So i added a spaceship sprite to the enemy and its rotating as expected. Everything is working perfectly even in game view.

But as soon as i built my game, the sprite just disappeared! I tried opening and closing unity multiple times and built but i got the same problem everytime

Game View in editor

Game Build

Btw the collisions still work but the sprite is not visible

Please help me this is perplexing :sneezing_face:

Hi,

If the sprite disappears but the collision works, this is very likely a rendering issue. Make sure that the “missing” sprite is not behind another sprite or behind the camera. The “missing” sprite must not share the same z-position as the background, or it must have a higher “Order in Layer” value in its SpriteRenderer component.

I hope this helped. :slight_smile:


See also:

If that were to be the problem, then it should be visible even in game vew also right?

Ok I just changed the order in layer to 1 and it worked lol

Thanks!!

Good job on solving the problem. :slight_smile:

The rendering order is arbitrary, hence we cannot make any assumptions in this respect. In the worst case, everything works perfectly fine on your own computer but your future players will complain because sprites randomly disappear. This issue is known as the infamous z-fighting effect.

When working with sprites, always make sure that overlapping sprites never share the same z-position and/or order in layer. Do that even if your sprites look correct on your own screen because you can never know if your future players will have the same “correct” random rendering order as you.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms