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.

  • Just sharing my tween animation for mob's die() functionLucas Pscheidt```gdscript func die(): if not is_alive: return is_alive = false enemy_die_sound.play() var die_sound_time:= enemy_die_sound.stream.get_length() await get_tree().create_timer(die_sound_time/3).timeout var tween := create_tween() tween.tween_property(sword_sprite, "global_position:y", global_position.y+35, die_sound_time/3).set_ease(Tween.EASE_IN) tween.parallel().tween_property(sword_sprite, "global_rotation_degrees", global_rotation_degrees + [-3.5,-3,-2,-1.5, 1.5,2,3,3.5].pick_random() * 5, 0.1).set_ease(Tween.EASE_IN) tween.parallel().tween_property(shadow, "scale", shadow.scale * 1.25 , die_sound_time/2).set_ease(Tween.EASE_IN) tween.tween_property(self, "modulate:a", 0, 1).set_ease(Tween.EASE_IN) tween.finished.connect(queue_free) ``` 3 2 Jan. 03, 2025
  • Still a little fuzzy on setters and collisionsGearheadgeekHi, I completed the challenges, but I'm still a little unclear on some nuances of setters: Setter questions: The syntax of the function declaration confuses me: 2. In the function declaration: func set_health(new_health: int) -> void:, I know we can explicitly pass the function a new health value, but how does it get passed this value when we modify its variable? Does it detect the change in variable, and then automatically take the new value to be the argument? When I first saw the syntax "func set_health(new_health: int) -> void:", I thought we would have to calculate a new health value elsewhere by first identifying the entity whose health we want to modify, referencing the health value and then passing the mob's set_health function the new calculated value which seems like an extra step. But, based on the bullet scene's interaction with the mob, that's not the case. 1. So, am I understanding it correctly that setter functions trigger when either their associated variable is changed **OR** when they're called directly? Collision question: What's the difference in usage case between area_entered and body_entered? 2 1 Feb. 25, 2025
  • Question about Health Setterfilthy-rookDuring the lesson I used the provided suggestion of func set_health(new_health: int): health = new_health if health <= 0: die() 3 0 Mar. 14, 2025
  • Setter Function Not WorkingPurpleHuesWhen I play the game the bullet still go through the sword enemy and doesn't take damage or die. I've been trying to figure if it's a collision issue or a script issue, but yeah.. Heres the script: [https://drive.google.com/file/d/1BqpoA-rMSZ0lGdCh2W6AYXTicWzUsotV/view?usp=sharing](https://drive.google.com/file/d/1BqpoA-rMSZ0lGdCh2W6AYXTicWzUsotV/view?usp=sharing) 5 0 Feb. 23, 2025
  • I get setter functions now!miserly-dugongI thought it would be useful for the teachers to know that I didn't understand the use case of setter functions until this section, it's so much clearer now that I know it's just a function running every time a variable is changed. Thank you! 1 0 Feb. 19, 2025
  • Question about set = set_healtholiver_gzzHey there, is there a lesson where we saw the logic on the `set = set_health` line of code that follows the **health variable?** **`var health := 100: set = set_health`** I do remember, using the `set_health()` function, but not like this. The way is suggested in this lesson, I think it's simpler and cleaner. 2 0 Feb. 04, 2025
  • The method to force update physics calculation?DMKHi, this is not a question specific to this lesson, but I'm finding that method that was in some lesson, that lets you force update the physics calculation, so that I can get the overlapping bodies of an area2d the same frame it's added to the tree. I'm pretty sure it was called something like force_update, but I don't know where it is. Or maybe I'm just hallucinating, and it never existed. If so, can you tell me how that would be implemented? 2 0 Jan. 21, 2025
  • Handling the mob's death soundHardRockFor this optional task one of the hints is that we should connect the the `finished` signal of the AudioStreamPlayer to `queue_free()`. However, I didn't want to do this, since it seemed to me that this would complicate things by duplicating the places `queue_free()` is called from (since one call would remain in the `die()` function as well, in case there is an enemy that doesn't have a death sound). Furthermore, it didn't really make sense to me that it should be the responsibility of an audio playback to delete an enemy. So instead I await the finished signal in the die() function itself like this: > func die() -> void: > set_physics_process(false) > audio_stream_player.play() > await audio_stream_player.finished > queue_free() Is there anything wrong with this approach? It's likely I haven't considered all scenarios that could crop up in a more complex project, but it seemed to me that this way the `die()` function would remain more easily extensible, since I wouldn't need to make sure that playing the death sound would be the last thing I do in it, like if I'd follow the challenge hint. 1 0 Jan. 05, 2025
  • Mob Health setterram876Hello. I wrote a code for a mob where I write a health setter like this (my initial code without checking for the existence of animation_player). ```gdscript func set_health(new_health: int) -> void: health = new_health if health <= 0: die() else: if animation_player: animation_player.play("hurt") _hurt_sound.play() ``` There I play an animation depending on the change in the amount of health. Everything was working correctly. But in the lesson where we work with pickup, I decided to change the health of the mob at the level through the editor. As a result, I get the error that animation_player and _hurt_sound cannot be started, since animation_player and _hurt_sound are not yet available when calling the setter. I added a check for the existence of animation_player to the setter and there is no error anymore. What would be the right thing to do in this situation? 2 0 Dec. 30, 2024
  • How can I know if a node is still in the tree?◆ LPUsing `if body is_in_tree():` or `if body is_visible in_tree():` gives error about expected ":" after "if" condition. Am I missing something? 3 0 Dec. 18, 2024
  • Missing kill.wav sound in mobs directoryRuben TeijeiroI think the kill.wav sound is in the common/sounds folder and not in the mobs folder. At least I couldn't find it. 1 0 Dec. 06, 2024
  • error _hit_boxCelsmissing hit_box ensure it is included in the @onready var. hit_box it's an important feature for melee mobs 1 0 Dec. 04, 2024
Site is in BETA!found a bug?