Sometime the bricks become transparent

Hi I don’t know why ,but sometimes while I’m playing the game some bricks become trasparent .Someone knows the reason .
thank you.

Screenshot:

Off the top of my head its because you dont have enough sprites in your sprite sheet.

I’m guessing your bricks sprite changes each time its hit. That way it shows it breaking down.

So if you have 3 sprites, Unhit, Some Damage, Lots of damage, your brick starts out showing the unhit sprite.
Then its hit once, and shows some damage sprite, then hit twice and shows lots of damage sprite, and then is destroyed on the third hit.

The problem I’m thinking your having, is your brick is taking more hits than it has sprites. So if you have 3 sprites, it should be destroyed on the third hit. But its not being hit, so when it changes sprites, it runs out of sprite so you end up with an invisible brick.


this is the screenshot of the hit sprites.I think it’s right because it has 2 hits and 1 sprite

i understood what is the problem but i don’t know how to solve it.Well it’s like if some blocks change their color with the color of the background.
screenshots:

At this point, we’re going to need to see the code that controls your blocks.

https://gist.github.com/anonymous/23740dfdacf029058137707ee99d3fb6

Hello @Alfonso_D_addio, can this topic be marked as [Solved] now?

1 Like

@Rob but it isn’t solved

Ah, ok, no problem, sometimes people get so excited moving on to the next part of the course they often don’t mark the [Help] posts as [Solved], so I was just checking :slight_smile:

So, what things have you tried since the last posts? @chris.claus42 mentioned about the sprite sheet etc, and you had mentioned about the background colour being the same as the sprites. What things have you ruled out so far?

In the last two weeks I haven’t programmed because I’m on vacation in LA.Do you have some solutions?I noted that when I’m playing the game and I destroy some blocks ,the blocks that are transparent become of their original color.
Thanks for the answer

Hope the vacation is going well :slight_smile:

Looks like there is only the one .txt file on the github link above, anyway you can zip up the whole project for me and pop it somewhere where I can download it? I will take a look if I get a few minutes and see if I can spot anything.

1 Like

Well… If I were to guess what the problem is, I’d say that the background and the bricks are at the same Z position, and when the game reloads the sprite (when you hit it) the brick might being reloaded inside the background sprite, thus rendering it as 50% background and 50% brick (giving the impression that the brick is transparent), if this is the case, if you set the background to a z position behind everything else this kind of problem shouldn`t happen anymore.

1 Like

I skimmed, didn’t read all the replies.

I’ve been struggling in GlitchGarden over the past few days with trying to put sprites on top of my background images. What I found is that if, under certain settings, the sprite is not below the background image in the hierarchy, it won’t display.

There are other settings that play in to this, like using a World Camera rather than what they’ve taught you so far, but this shouldn’t be a problem unless you have something pretty far off the beaten path of this course.

May not help, but I thought it was worth mentioning.

Im having the same problem!
I have set the same color settings for my two “bricks” yet one of them seem to be somewhat transparant. I dont understandy why that could be!

Oh I just realized why: the transparant prefab has a z value that puts it behind the transparant background!

I would also make sure that your brick script is not resetting the z value of the brick every time a new sprite is rendered … that was happening with my paddle … even though I was manually resetting the paddle to be in front of my background each time it would somehow move back when I hit play. Turns out that the moment I hit play the script kicked in and sent the paddle back 1 world unit along the z axis without me realizing :sweat_smile: