Use this space for questions related to what you're learning. For any other type of support (website, learning platform, payments, etc...) please get in touch using the contact form.
Problem with "Can't I stop the tweens instead of disabling the button?"pikminfan71I didn't understand how to do it, the tween is already inside a variable isn't it?
I'd love some help with this, thanks in advance!
23Jun. 01, 2024
Shortcut interferenceold-fashioned-jackalI noticed some issues when combining shortcuts with the other forms of input. If my "next" button is in an active state, such as after clicking it, then pressing space or enter will press the button as per the shortcut, then press it again when released. In effect, this means pressing the key skips over a line of dialogue. (Likewise, if my "previous" button for rewinding the dialogue is active, then the result is getting stuck on the same line of dialogue.)
It feels like shortcuts are not meant to be used in combination with the usual methods of pressing a button by keyboard or mouse. Should we be disabling other input methods when using shortcuts, or is there a way to make them play nicely together?
I also noticed when hovering the cursor on the "next" button, a tooltip pops up saying (Enter(Physical)). This could be useful information, but it looks a bit cluttered/unpolished for a final product (extra parentheses, and the "physical" bit might be confusing or unnecessary to the end user) and it is incomplete (I have three inputs mapped to this action, but only the first is shown). Is there any way to modify this?53May. 20, 2024
Different solution to stopping the tween instead of disabling the buttonrobert_copHi, this seems like a good place to put the solution I came up with, I think I came up with it in the lesson where the text tweening was first introduced. I wanted the button to have a certain behavior, where if you click it while the text is still appearing, it will set the text to fully visible instead of advancing to the next line. This is what I came up with:
```gdscript
func advance_dialogue() -> void:
if dialogue_label.visible_ratio < 1.0:
dialogue_label.visible_ratio = 1.0
dialogue_tween.kill()
audio_stream_player.stop()
else:
current_item_index += 1
if current_item_index >= dialogue_items.size():
current_item_index = 0
slide_in()
show_text()
```
```gdscript
func previous_dialogue() -> void:
if dialogue_label.visible_ratio < 1.0:
dialogue_label.visible_ratio = 1.0
dialogue_tween.kill()
audio_stream_player.stop()
else:
current_item_index -= 1
if current_item_index < 0:
current_item_index = dialogue_items.size() - 1
slide_in()
show_text()
```
As you can see, instead of checking if there is a tween, it checks if the visible_ratio on the label's text is less than 1.0 (so it checks if the text is still appearing), if this condition is true, it sets the visible_ratio to 1.0, kills the tween, and stops the sound. Else, if the text is already fully visible, it advances to the next line.
If anyone was trying to implement something similar, feel free to take notes, I'm pretty happy with how it came out.32Jul. 31, 2024
Two tween signal connectionsliuti_devWhen I tried to add the button disabled code inside the tween finished signal (line 95 *but turned to a lambda function* like at line 102) the button worked as intended but the sound wouldn't stop. It only works separating into two functions. Why does it happen?41Jun. 13, 2024
"Tooltip" when hover buttonsilver-foxI see a "Tooltyp" (KP Enter(Physical)) when hover the button. How do you disable it? and it is custumizable?10Nov. 12, 2024
Connecting two times the same signalPurpleSunriseHello,
I was just curious to know more about connecting two times the same signals. Is it better to do everything with a lambda as argument of one signal or have two same signals?
Also in this case, the tween emits the same signal twice right? The first signal stops the audio and the second one re-enable the button?
Could you just write:
```gdscript
tween.finished.connect(func() -> void:
audio_stream_player.stream.stop
next_button.disabled = false
)
```
Just curious to know if it's going to affect performance or which one is the "best practice"?
Thank you!20Nov. 05, 2024
Question about tween.kill()milk_manI followed the steps under "Can't I stop the tweens instead of disabling the buttons?". But when I run the scene, no text appears and the audio_stream_player plays until the end.
I just wrote the following line of code:
```gdscript
if tween != null:
tween.kill()
```
and put it at the end of the show_text() function. I don't undertstand how I'm supposed to store the previous tween in to a variable. 30Oct. 21, 2024
Enabling dialogue in the gameram876At this stage, I have a question, but how to include a dialog system in the game? For example, a character approaches an npc, presses the dialogue button, a dialog box opens on top of the game (we do not move to a new scene, namely, the dialogue is drawn from above the game world), we speak, receive information and a task, end the dialogue, the dialog window closes.20Oct. 20, 2024
Button pop-up windowram876When you hover over the button, a pop-up window with the name appears. How to remove it?
[https://screenshare.ru/s/96oBSepAAjFbVoH3kaLBn](https://screenshare.ru/s/96oBSepAAjFbVoH3kaLBn)20Oct. 20, 2024
Using Signals to stop the Tween when Next Button Pressed for the Mini ChallengeiguessfiveEarlier in this module, in the comment section I found a great and simple solution to stopping the text when the next button is pressed. I didn't see it here, so for anyone interested I wrote it below.
If anyone wants to try to figure out how to use signals to stop the Tween from playing when the next button is pressed then wait to look below.
```gdscript
signal new_text
func show_text():
# ...
new_text.emit()
new_text.connect(tween.stop)
```10Sep. 01, 2024
What is the difference between using InputEventKey and InputEventAction? Lucas PscheidtWould it work in the same way?10Aug. 27, 2024
Stopping the tweensTJHi! In the info-box about stopping the previous tween, it says:
"If the tween is still present, it means text was still appearing when the player advanced the dialogue."
I think the tween object can still be there even when it has finished playing. I did some experiment by putting a breakpoint on just the following condition that is recommended by this info-box:
```gdscript
if tween != null:
tween.kill() # breakpoint here
```
Here, `tween` was first converted to an attribute in the script, moved to the script-scope so it persists between calls to `show_text()`.
During debugging, GDScript does break here even after I waited long enough for the current text to have fully appeared and the sound to have stopped. I learn from this that GDScript does not set the attribute `tween` to `null` after the tween has finished. So what remains after a tween has finished is an actual object in memory but it's no longer actively tweening anything.
From this experiment, I would propose to use the following condition to guard usage of the `kill()` function:
```gdscript
if tween != null and tween.is_running():
tween.kill()
```
What do you think?20Aug. 16, 2024
Function slide_in =/= animateSophiaSliding lessonHazlarJust to point out that the reference code for the slide_in function is not written quite the same way as the one covered in the lesson [https://school.gdquest.com/courses/learn_2d_gamedev_godot_4/telling_a_story/animate_sophia_sliding_in#recap](https://school.gdquest.com/courses/learn_2d_gamedev_godot_4/telling_a_story/animate_sophia_sliding_in#recap) 30Aug. 15, 2024
Shortcut button problemAphexI put spacebar and left mouse button on the advance_text input map, when the game is running only the spacebar works.10Jul. 30, 2024
Button VisibilityfledgerI was just curious if you there is any benefit to using disabled instead of visible in this scenario.
Would visible just be better for "game juice"? 70Jun. 03, 2024
Issue with the pressed theme while using keyboardEddyAs the title say, when I use the spacebar of my keyboard as a shortcut, my next_button does not animate properly. The animation when I use the spacebar is like my "disable_button" (black backgroud and grey letters.). Nevertheless when I check in my main_theme file and when I use the Left-clik of the mouse, it works properly. I tried to find a solution in the Inspector and the main_theme panel but can not find a clue.
Is it a display issue or something else I don't undersant? Otherwise it works like a charm. 60May. 26, 2024
Lesson Q&A
Use this space for questions related to what you're learning. For any other type of support (website, learning platform, payments, etc...) please get in touch using the contact form.