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.

  • Code error in 'How do I prevent the player from taking damage too frequently?'DMK`if body is Player and not _cooldown_timer.is_stopped():` This part seems wrong. The intended logic is that the mob should only be able to damage the player when the cooldown timer is not running, i.e. stopped. But in this code, it's the opposite: the mob can damage the player only when the cooldown timer IS running. It should be `if body is Player and _cooldown_timer.is_stopped():` 1 0 Jan. 15, 2025
  • Good looking health barPJIs the stylebox in the fill of your healthbar a dedicated texture, or did you apply some effect on build in styleboxes? 2 0 Jan. 06, 2025
  • Camera handling on player deathHardRockIt bothered me that when the player dies and we call `queue_free()` the camera jumped back to the initial position in the level. It makes sense though, since the player's Camera2D node is deleted in this case as well. To avoid, this instead of calling `queue_free()` on the player I simply set the player to be invisible for now (I still disable the player's physics and collision). This way the camera stays in place when the player dies. This issue made me wonder though, would it be possible to set up a camera in the level instead (or anywhere higher than the player in the scene tree) and make it follow the player? I feel this would be a better solution, especially if in a more complex game I would need to change the camera behavior for a cutscene for example. EDIT: Looking at the Camera2D node's documentation I see that it would be possible to create a custom camera by transforming the canvas as I need it, so I may experiment with that eventually, but I wish it would be possible to set up some overrides for the Camera2D node instead (like how to behave when the followed node is destroyed, or which node is being followed). 2 0 Jan. 05, 2025
  • var previous_healthPJWhat is the purpose of creating such variable in setters? 1 0 Jan. 05, 2025
  • Mixing cooldown & damage timerMoKTHey Nathan and Jad, at first I didn't see the need for a cooldown timer, so I added in a damage timer which worked great until the player collided with the mob at a weird angle, which caused double damage to the player. I tried to mix the damage timer & cooldown timer but it would either not cause any damage, or continue dealing double damage. The cool down timer node is set to 1 sec, with oneshot is enabled. Solution attempt 1 - still leads to double damage ```gdscript func _on_hitbox_body_entered(body: Node2D) -> void: if body is Player: damage_timer.start() damage_timer.timeout.connect(func () -> void: body.health -= damage ) if body is Player and not cooldown_timer.is_stopped(): body.health -= damage cooldown_timer.start() func _on_hitbox_body_exited(body: Node2D) -> void: if body is Player: damage_timer.stop() ``` Solution attempt 2 - no damage is dealt ```gdscript func _on_hitbox_body_entered(body: Node2D) -> void: if body is Player and not cooldown_timer.is_stopped(): body.health -= damage cooldown_timer.start() damage_timer.start() damage_timer.timeout.connect(func () -> void: body.health -= damage ) func _on_hitbox_body_exited(body: Node2D) -> void: if body is Player: damage_timer.stop() ``` 9 0 Dec. 30, 2024
  • Hands still moving when Player is deathRuben TeijeiroIt seems disabling the physics_process on the player is not enough to avoid its hands to keep moving so I also disabled processing with set_process(false). Is that correct or is there any other better way to do this? 1 0 Dec. 06, 2024
Site is in BETA!found a bug?