- Home /
GameObject disappearing when switching to Game View
I have a GameObject called "CoinObject" that disappears when I enter play mode, even before I hit play. When I'm playing the game and switching to Scene View the object becomes visible and the animation is working. the object is based on a prefab but the problems began before I parented it, so I don't think it has something to do with that. I've tried to recreate the object and to reinstall Unity but it didn't help. I also checked the Sorting Layers and there are no problems there. Is it a bug? Can someone help me please?
Answer by kevinhart1001001 · May 05, 2021 at 09:57 AM
The Position is Z-453! way to far away, even if the game is 2d, there is still the Z axis. The Camera is by dafualt at z -10 and looks in positiv direction (you see everything "above" -10). You should change the Z Axis to at least -9.
Thank you so much!! now its working. I didn't knew there's Z axis in 2d...
Answer by Iarus · May 03, 2021 at 03:23 PM
I'm not a pro or anything, but the first few things I'd try would be:
while the game is running, check if the game object is still in the scene hierarchy. If not something in your code is killing it.
if it is in the scene hierarchy, is the game object active? Are all components there and active?
the object's transform (position, rotation, scale) are affected by the parent's transform. While the game is running, switch between the game view and the scene view and validate if object are where you expect them to be.
check the settings on your camera, there should be a property for "near plane" and "far plane", maybe it's "distance" instead of "plane". This determines what gets rendered, it must between these 2 values. Pull back your camera or decrease the near plane value or increase the far plane.
I tried now, it didn't worked... thank you for your suggestion!