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.
Stoping the mobs as welloliver_gzzHey there, what if the player reaches the teleporter, and there's still enemies around and within reach, how can we stop their physics process as well?
I tried this, on the *teleporter.gd* I created a **var** and **a function,** and then added the function within body_entered's lambda **(but is not working)**
```gdscript
var _enemies_in_scene : Mob = null
func pausing_mobs():
if _enemies_in_scene == null:
pass
else:
_enemies_in_scene._physics_process(false)
##I've added the pausing_mobs in the body_entered lambda
func _ready():
body_entered.connect(func(body:Node2D):
if body is Player:
_player = body
var win_screen := get_tree().current_scene.get_node("/root/Node2D/CanvasLayer/WinScreen")
win_screen.win_game()
body.toggle_player_controls(false)
pausing_mobs()
)
```21Feb. 24, 2025
Blur & Tint ShaderGHi,
I was wondering, there is anyway to fix the shader so it will work on a browser?
How do I know if a shader performs post-processing?11Feb. 11, 2025
Why not use get_tree().paused ?miserly-dugongThe solution you suggest seems so much more convoluted, I'm wondering if there's a reason why we're not using this method:
`get_tree().paused = true`10Mar. 15, 2025
Shader for menu not working when menu scene is childGearheadgeekHello! I got the teleporter working, and then I was reminded by the end of lesson tips that I could use the blur shader to make the colorrect node look cooler when the menu appears. I've added the shader to the colorrect node of my end menu scene (the structure is almost exactly like the pause screen from top down movement). However, the shader is not displaying outside of the end menu screen.
By this I mean that the shader displays correctly when I run the end menu scene itself, but when I made the end menu scene the child of the teleporter or the game scene, the shader doesn't display! The menu, time elapsed, and "You won!" label are all visible, but the shader isn't working. Is there something special I need to do to make sure its visible?
Edit: More specifically, the colorrect node with the associated shader is refusing to appear outside of the end screen scene.
This is my menu script:
```gdscript
extends Control
@onready var time_elapsed_display: Label = %TimeElapsedDisplay
@onready var restart: Button = %Restart
@onready var quit: Button = %Quit
var start_time : float
func _ready() -> void:
start_time = Time.get_ticks_msec()
visible = false
restart.pressed.connect(func() -> void:
get_tree().call("reload_current_scene"))
quit.pressed.connect(get_tree().quit)
func end_game() -> void:
var end_time : float = Time.get_ticks_msec()
var time_elapsed := end_time - start_time
time_elapsed_display.text = "Time: " + str(time_elapsed / 1000.0) + "s"
visible = true
```40Mar. 02, 2025
I never expected to get this farEndeiosHi Team!
I reused part of the pause logic in M09 for the win screen, and I am very satisfied with the result: I even let half second for "turning on" the teleport. Maybe I will need to revisit the choice in the end menu, but I am very satisfied of the game at the end of this chapter.
Thanks again for this amazing product: I never thought I could get this far, with a game that appear much more polished than my other experiments.10Mar. 01, 2025
Assiging a reference to the menu node in the teleporter?SpellingSwordAre there any drawbacks to using something like:
`@export var menu: WinMenu = null`
inside the teleport script and dragging the menu there inside the main game scene?
This way you don't have to attach a script to the root node - or put the teleport logic there if you already have one.10Feb. 10, 2025
My code + a questionmilk_manSorry for the barrage of questions lately. Firstly, here is my code:
teleporter.gd:
```gdscript
extends Area2D
@onready var menu: Menu = %Menu
func _ready() -> void:
# deactivates player controller
body_entered.connect(func(body_that_entered: Node2D) -> void:
if body_that_entered is Player:
if menu == null:
return
menu.toggle_menu()
)
```
menu.gd:
```gdscript
class_name Menu extends Control
var start_time: int = Time.get_ticks_msec()
@onready var _time_label: Label = %TimeLabel
@onready var _play_button: Button = %PlayButton
@onready var _quit_button: Button = %QuitButton
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
visible = false
_play_button.pressed.connect(func() -> void:
get_tree().paused = false
get_tree().reload_current_scene()
)
_quit_button.pressed.connect(func() -> void:
get_tree().quit()
)
func _input(event: InputEvent) -> void:
if event.is_action_pressed("ui_cancel"):
toggle_menu()
func toggle_menu() -> void:
var end_time: int = Time.get_ticks_msec()
var time: float = (end_time - start_time) / 1000.0 # divide by 1000 to get time in sec
visible = not visible
if visible:
# snappedf rounds in this case to nearest 0.01 sec
_time_label.text = "Time: " + str(snappedf(time, 0.01))
get_tree().paused = not get_tree().paused
```
I must say I kind of enjoy the style of using smaller, node specific scripts rather than large and broad scripts. Anyways, I saw that under the hints, when talking about how the teleporter script could toggle the menu, making the menu unique wasn't mentioned as a possible solution. That made me kind of unsure. Isn't it a simpler solution then what is proposed under the hints
30Feb. 05, 2025
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.