Disappearing sprites?

Beginner here (hello!), did a search of the forums for “disappear + sprites” and didn’t come up with much so I know it’s probably a me problem. Not sure what I’m doing wrong. Not new at computers or editors etc, but new at Defold. Been following a few youtube tutorials and am on my 2nd series, this one is the Unfolding Gamedev 3-part “Space Shooter” for beginners.

I’m grasping all the concepts pretty easily, but what seems to have been happening is that sprites seem to randomly stop appearing after rebuilds. This has happened about half a dozen times, and I mean in the simplest of examples with literally 1 or 2 sprites on screen. This latest tutorial has a ship on the bottom and an enemy above it. I decided to move the enemy sprite over about a dozen pixels, I did a quick CTRL-S, CTRL-B, and the enemy was gone. My ship was there, I checked the code, everything was the same, the png file is there, the code is all there, nothing else was changed. Like I said before I’ve had to do this now about half a dozen times where I’ve basically had to start the tutorial over from the beginning, deleting all the game objects and recreating them to get them to reappear. I’ve scoured the forums for anyone else having the same issue and I don’t see anything similar, so I’m guessing it’s me. I’ve checked, double-checked, triple-checked, I don’t have alzheimers, I’m quite competent, never have this issue in other tools, but there’s something going on and I just can’t figure out why sprites are disappearing at random. There are no errors in the console. What should I be looking for?

Sounds like a graphics driver issue to me. Assuming you’re on Windows, go to the website for your graphics card’s manufacturer and make sure you have the latest drivers installed.

Good idea! I was one GeForce version behind. I took a before image: https://imgur.com/TXnvJ1U

I updated the driver to the latest, reopened Defold and the project, but unfortunately it’s the same result.

I added the same game object a second time, and it appears correctly: https://i.imgur.com/HYhvBA8.png

Did you restart your computer as well? Just restarting an app isn’t enough to apply driver updates.

Yes, restarted. I’m not familiar enough with the debugging yet to figure this out.

Often users don’t realize they have an integrated (often Intel) graphics card.
Could this be the case for you as well? If so you might need to update that driver instead.

Please, take a look this post HELP I dont underand it anymore {SOLVED UPDATE INTEL} - #11 by AGulev maybe it will help

1 Like

Thank you both, that post does seem to be similar what I’m seeing. I did install and run the Intel driver & support assistant, it found “no supported or updateable driver available” on my system. I keep my system generally fairly up to date. Defold has gone through 2 updates for instance during the time that I’ve been using it. Windows is up to date. I think my next step is to install Defold on my laptop, copy the project there and see if the problem exists, and I’ll report back here. It’s a different brand, different graphics, etc. That should narrow down the scope of the problem.

I installed Defold on my laptop and copied the project over. It has the same problem. My (older) desktop is Windows 10 Pro with an older Nvidia graphics card, while my laptop is a newer Windows 11 Pro HP with a newer mobile Nvidia. It’s making me think it’s less likely a graphics driver issue and probably something I did when I dragged the sprite over a bit. Is there something I can show you here that you can look at to confirm it should be visible?

Just make a zip archive of the project and attach it to a post, and we’ll have the whole community take a look at it!

Maybe you set sprites z = -1.0, and because of inaccurate calculations they can now disappear from the viewport.

1 Like

Super simple! As I mentioned in the first post, it was visible, then I moved the “enemy” sprite from directly above the player ship (where it was working just fine) over to the right a bit so it was out of the way of the bullets (and the collision object too), when suddenly the sprite disappeared on the next build. I later created another enemy sprite called “this_enemy_is_visible” just to see if it was a problem with the sprite but that sprite appears just fine.

SpaceShooter.zip (42.6 KB)

Good news is your drivers are fine. The enemy game object position is set outside of rendering near/far bounds. The default render script renders game objects in the near/far z plane between -1 to 1 and your enemy position z is set to 7.0 causing it not to rendered. You can set your game object z positions anywhere from -1.0 to 1.0 so using small float numbers is ok example 0.1 , 0.35 , -0.2 , -0.3 ect. Note that if you change components positions like a sprite it will result in cumulative values same with parented game objects, so say your game object z position is 0.1 and your sprite z position is 0.1 this will result in 0.2 so keep this in mind if visual components start to disapear.

to fix: Changing your enemy z position to anything between -1.0 to 1.0 will be rendered.
Good read > Camera component manual

3 Likes

@aglitchman mentioned the Z-axis earlier on, and I was also aware that I should probably check the coordinates, so what I did is check this (see picture). I read the Camera component manual (thanks for that). But I don’t understand why there’s an XYZ for the g.o. as well as for the sprite. I looked at the X= -24 / Y=19 and couldn’t figure out what that was in relation to. Now I assume it’s in relation to the g.o.'s XY I’m assuming? Can someone explain how me dragging the sprite over with my mouse caused the sprite value of Z to change? Is the a hotkey (ie shift, ctrl, alt) I may have accidentally pressed while dragging that might have changed that value?

1 Like

Yes, the sprite xyz is added to the game objects xyz, and any parent game object xyz too.

No, can you reproduce it?

Yes I figured out how to reproduce it. In the following image, when I click and hold box A and move the object, it changes the Z value. When I move it using box B, it does not change the Z value. What is the difference between boxes A and B?

There should be none. What you describe sounds really strange. I suppose if you have your game object rotated around the Y-axis and then do Edit->Local Space, then any movement using either A or B would also affect the Z-value. But that doesn’t seem to be the case here…

If I may use an analogy (it may be a rough analogy, because I’m new at this engine). Say I buy a car, and it has 2 steering wheels, A and B. Steering wheel B is like any normal car, it turns the car in different X/Y directions on the street like any normal car. But then I wonder, what does this steering wheel A do? Suddenly it launches me vertically into the sky. This is what control box A is doing. And every else here is using the same game engine, so what is it doing for you? Can you not replicate my results? Alternate way of asking this question: when you want to move a sprite in 2D (x/y space), how do you do it?
(PS Merry Christmas!)

If you accidently held down CTRL + Left Mouse and slightly moved the scene view out of zeroed 2d position into a perspective view then you use the free move box (the orange square) this would contribute to the z position being changed. This is not a bug or anything like that. To solve your issue you can reset the view by pressing the ( . ) period key or in the menu View > Realign Camera.

1 Like