Question on Ball Breaker Game

I have a question. I have not completed my second level yet because I have an issue on Level 1…

First here is my level… And this should consistently be my start state.

Next, my issue…

When I lose the game, it goes to the “Game Over” Scene, which is what it is supposed to do. I then hit the “Play Again Button”, and it goes back to the “Start Menu”, which is what it is supposed to do again. At that point, I hit the “Start Button” to restart the game… One of two things happen here when I click the "Start Button.

1 - It restarts the game in it’s original state, which is like the picture above.

OR

2 - It restarts in some state similar to the picture below. It’s won’t be exactly the same. Different blocks come and go “at times” when I hit the Restart Button. And then it will restart in the original state again at some point. It’s like it has several start states and it chooses which one to use.

This is one such instance below. This is before I have started the game. This is the start state. I lost and hit just hit the “Start Button”.

There is no rhyme or reason to it. My starting state varies each time I hit the Restart button…

And my settings:

If anyone has any ideas on this, I would appreciate it. Thanks in advance…

Just FYI, I even tried recoding it and choose a different option in the SceneLoader area… Of course, that did nothing so I took it out of Visual Code.

I’m at my wits end. I’m sure it’s something simple. It HAS to have something to do with Level 1.
Before I move one, this has to be fixed. I’m digging this morning trying to find the solution. Thinking about recreating all the blocks.

Jenn

I deleted all my blocks. I’m redoing Level 1 and watching the pertinent videos once again. I’ve done something wrong. I hope this works…

I just thought of something… Something I noticed this morning. I wonder if the issue is because when I was creating my level I yesterday, I deleted my main block. It was gone today when I was checking out my level. So I deleted it yesterday by mistake and didn’t notice until today.

I wonder if that’s the whole issue in a nutshell. What made me think about that is because I deleted all my blocks while ago. I made four prefabs from another original block. The game with these little five blocks is playing just fine so far.

Jenn

This might be caused by a lot of different things, but first check if the blocks are still there, then you can procede accordingly.

If blocks are still there but the sprite is not showing up:

  • In Sprite Renderer settings of both the objects in the scene and your prefab:
    • Check if the Order in Layer is bigger of that of your background, if the Order is the same as your background, some objects will render after the background, so they are still there, but in the back.
    • Check if it is activated.
    • Check the color, maybe it is transparent for some weird reason.
    • Check if it has a sprite.
  • Check the scripts that might be manipulating the Sprite Renderer. (I think there’s none at this point in the course)

If the blocks aren’t there.

  • The blocks are probably destroying themselves. Check the script that destroys them. If there’s nothing wrong some of your blocks might have a Ridigbody attach to them making them trigger the destroy script, check for that.
  • What do you mean by “main block”? The prefab? I don’t think deleting a prefab could cause any of this, but it could be a Unity bug.
  • If your blocks are being destroyed I suggest your write this line of code in the Block script:
public class Block : MonoBehaviour {

    private void OnCollisionEnter2D(Collision2D collision)
    {
        print("I'm being destroyed by: " + collision.transform.name); // Add this
        Destroy(gameObject);
    }
}

This will give you enough information to find out what is going on. If the message never prints in the console and the blocks are being removed, then it’s probably a bug, and yes, prefabs might be causing this.

Thank you!!! I will get this figured out… I appreciate your help! The blocks WERE still there but just transparent. If this happens again I will know what to do. I am saving your entire answer on my desktop for reference.

Jenn

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms