简体   繁体   中英

why are the spawned game objects with Instantiate are invisible in game but visible in scence when i press play in unity (2d game)

在此处输入图像描述

I don't know what can cause this problem , those game objects : enemy (spawned) can't see them in game I need your help thanks in advance .

There could be many issues as we don't have very much information. First make sure the instantiated objects' Z coords are in front of the Camera and not behind the backround.

If they are sprites, the 'Order in Layer' property may be set up wrong. If you never changed the layer order, they will all be 0s, and can therefore appear in any layering. In this case, the background appears on top of the sprites, because it doesn't know which to render in front. Change your ghosts to have a value of 1, and the background to be 0, and they will appear in front

There are some possibilities:

  • The object is too close to the camera. In this caso you can try to reduce the camera's near distance. Also they can be very far, so you would have to increase far's distance.

  • When sprites are in the same layer, they might appear randomly in front or behind the others. If this is the case, try to let the players' order in layer bigger than the background order in layer.

  • The objects might be in a layer that the camera doesn't render. In the property Culling Mask of the camera, check if the layer of your objects is marked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM