#[Solved] Following Brick Breaker Tutorial - - UI Node Preventing Boot

37 messages · Page 1 of 1 (latest)

hollow ember
#

Hello, I am new here.

Im working alongside this tutorial to make a brickbreaker game:
https://www.youtube.com/watch?v=4rWW2uvsziM&t=2657s

At 44:18 in the video the programmer runs his game and gets the UI to show, however the code I copied from him doesnt produce the same results for me.

I think I have tracked down the issue to a few lines, and please forgive me for the silly questions that are about to follow.

Here are my two errors.

Image 1 is the ball.gd script, image two is its corresponding error.
Image 3 is the ui.gd script line that I suspect is the real issue

My main question is for image 3, what exactly is the %d doing and after that the "% lifes"
I just wrote what the tutorial said but he didn't explain what these commands are and ctrl clicking them doesn't open in help info.

Any help appreciated, watching this on the side so I can reply quickly

Get ready to take a nostalgic trip back to the arcade era with our latest game development tutorial! 🎮 In this video, we dive into the exciting world of game development using Godot 4 to recreate the beloved classic: Brick Breaker! 🧱🚀

🔴 Watch as we guide you through the entire process of building this iconic game from scratch. From setting up t...

▶ Play video
golden ivy
# hollow ember Hello, I am new here. Im working alongside this tutorial to make a brickbreaker...

Hey!
That error means that nothing is assigned to the ui variable in your script. ( It is "nil" which means that it is basically nothing, and nothing doesnt have the "set_lifes" function)
I see in the video that it is an export variable. Did you assign the UI node in the editor? (timestamp: https://youtu.be/4rWW2uvsziM?si=tXS05x4lsl_yC2v9&t=2628) It should look like in the attached image for your ball node.

Now to what they do in this line: ( You can read about that here https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_format_string.html)

lifes_label.text = "Lifes: %d" % lifes

The goal is that you have the string "Lifes: 2" if the variable lifes is 2.
The %d is a format specifier and means that it will expect a decimal number (it is like a placeholder).
The % operator after that string just means that this placeholder will be replaced with the value in the lifes variable.

hollow ember
#

I believe I have the UI Node assigned, here is an image of that , this image include a view of the UI Script

I cant help but notice my text colors are not the same as the video, nor your text. Is this cause for concern?

#

most of the ball script is here

#

Thank you for the %d explanation, this makes sense

golden ivy
#

Hmm could you show your scenetree of the UI scene? Another thing could be that you didnt make the label unique

hollow ember
#

Sure, incoming

golden ivy
hollow ember
#

Colors are different in this image

lifes_label.text = "Lifes: %d" % lifes

#

Here is the UI Node,

No pressure if its bedtime haha , thanks for popping in to help regardless

golden ivy
hollow ember
#

Do i need a pass line?

golden ivy
#

na dw i just typed that in my editor quick to check the color haha

hollow ember
#

i see

golden ivy
#

hmm you run the correct scene right?

#

the one that has ui and the ball

hollow ember
#

Yea I was able to move the paddle and bounce the ball before adding the UI

golden ivy
#

if you want: can you zip the project? maybe i can find the issue quicker and im just not seeing the obvious right now

hollow ember
#

sure 1s

golden ivy
#

found the issue

#

It sounds stupid but it is just how the enginge works:

#

I swapped the order of ball and ui

#

In your ball:
this ready function gets called when the ball entered the tree.
At this point in time there is no UI node in the tree though.
There is a certain order in which the ready function of each node in the tree gets called.
First the children and last the parent ( to make sure the parent has full control over all the children)
For the children the order is from top to bottom.

#

So if the UI node is above the ball, it will be in the tree first before the ball

hollow ember
#

Very helpful,

I changed the order in mine, but am still getting a "Breakpoint" Error on the lifes_label.text line

#

Thank you very much for your time , patience, and help btw

golden ivy
#

No problem, glad i could help!

golden ivy
hollow ember
#

if i click skip breakpoint i get the screen

golden ivy
#

you had this when i opened the project. The project will run until this breakpoint (that you usually set for debugging purposes) but you can remove it by clicking on it

hollow ember
#

oh i must've clicked that by accident

#

Thats a useful tool!

Ok I think I am solved here, just needed the tree reorganized so the lifes could be generated / populated before being called upon by the ball script

#

Thank you so much @golden ivy!

golden ivy