Looks like you're not logged in

Login or Register to continue

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.

  • 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. 3 4 Jul. 31, 2024
  • 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! 2 3 Jun. 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? 9 3 May. 20, 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? 1 1 Nov. 12, 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? 4 1 Jun. 13, 2024
  • Input String TyposMr-Edin order to avoid typos you can actually go to the Input Map and click the name of the input, then just ctrl+c the text and ctrl+v where you need it. 1 0 Dec. 12, 2024
  • Shortcuts only work when the button was already clickedJohnyWuijtsNLIf I press enter or space, the button gets highlighted for a second, but nothing happens. If I click the button, making the purple outline appear around it, then pressing enter or space advances the dialogue as expected. I also made a back button and added a shortcut to that, but that one doesn't work at all, not even after clicking it. 5 0 Nov. 30, 2024
  • Speed up instead of disabling the buttonma9nificoInspired by @robert_cop's nice solution to have the text appear immediately instead of disabling the button, I wanted to have the animation speed up instead. This was a fun mini-challenge as it involved looking up both how to speed up a running tween (if it was at all possible) and the sound. Here is my solution. First, at the top of the file I defined two new variables: ```gdscript var speedup_scale := 3.0 var tween: Tween ``` In `show_text()`, I removed the line that disabled the button, and updated the code that handles the tween to now read like this: ```gdscript func show_text() -> void: # ... everything else but the tween ... tween = create_tween() tween.tween_property(rich_text_label, "visible_ratio", 1.0, text_appearing_duration) tween.finished.connect(func() -> void: audio_stream_player.stop() # The pitch scale must be reset, else the next play would also be sped up audio_stream_player.pitch_scale = 1.0 next_button.disabled = false ) ``` In `advance()`, check if the tween is still running, which means that the click on the button is done while the animation is still running, to call our new function to speed things up. ```gdscript func advance() -> void: if tween.is_running(): speedup() return # ... rest of the function as it was ... ``` And finally, here is the new function to do the speedup. Note the `speedup_scale` variable defined in the top of the file used here, which I've set to 3.0 for a 3-time speedup. ```gdscript func speedup() -> void: tween.set_speed_scale(speedup_scale) audio_stream_player.pitch_scale = speedup_scale # Disallow any additonal speedup next_button.disabled = true ``` If you wonder "what about the slide-in animation?", you are indeed correct that I don't do anything about that. Since I have set the slide-in to animate so quickly, even a 3x speedup to the text haven't caused that animation to complete before the slide-in, so I've left that be as-is. I hope someone finds this useful! šŸ˜Š 1 0 Nov. 30, 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! 2 0 Nov. 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. 3 0 Oct. 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. 2 0 Oct. 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) 2 0 Oct. 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) ``` 1 0 Sep. 01, 2024
  • What is the difference between using InputEventKey and InputEventAction? Lucas PscheidtWould it work in the same way? 1 0 Aug. 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? 2 0 Aug. 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) 3 0 Aug. 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. 1 0 Jul. 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"? 7 0 Jun. 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. 6 0 May. 26, 2024
Site is in BETA!found a bug?