Search code examples
unity-game-enginerenderinginstantiation

Dynamically instantiated prefabs are invisible


Now I know that this is a common problem and there are so many mistakes that would lead to it, but I have searched and seen all the results and answers in unity forums and other websites, and I'm sure that I don't have any beginner-mistake that would lead to it.

My problem is -Like the title states- that I have a "platform" prefab and I have a script, attached to some game object in the scene, that instantiates a new platform every x seconds. Now, the scripts works and everything is fine, the platforms are instantiated and they are moving and functioning as they should, but I can't see anything from this!

I mean that I can see them in the scene view window, where everything is fine, but in the game view window nothing appears, though I can interact with the platforms, such as landing on them and so on...

enter image description here


Solution

  • check the z depth... your probably instantiating them behind your camera. a good way to check is to start the game, go to scene, and take it out of 2d, then click one of the platforms in the explorer, and check its z value