godotengine / godotengine/godot-docs
Improve using signals page
- Dominant language
- reStructuredText
- Stars
- 5.7k
- Forks
- 3.8k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 25
Description
**Your Godot version:**
4.3
**Issue description:**
As well as the connect method, there is a disconnect method. There is no mention on the using signals page as to when or if you need to use it and I think there should be. For instance if you have removed entities from the scene tree, should you disconnect signals you connected to them so they don't still get informed, then re-add them when putting back into the scene tree? Is it good practice to remove connections that won't be needed anymore, e.g. an enemy dies so it won't need it's hit/die signals anymore, but it still existing because you've left it's model lying on the floor? I presume if you do a queue_free then connections are removed automatically, but this may not be the case as nothing about this subject is mentioned.
The connecting a timer via code section seems missleading.
The example would probably make more sense if the the thing to connect (in this case the Timer) was created via code rather than added in the scene dock and just looked up in the code via get_node. By adding it via the scene dock you can connect it in the editor via the node tab.
The example should probably do that rather than the bit about adding the Timer via the scene dock. I'd suggest removing that stage and changing the code to something like this gdscript (I don't know what the equiv C# code would be so I can't update it myself):
```
extends Sprite2D
var speed = 400
var angular_speed = PI
func _ready():
var timer = Timer.new()
timer.autostart = true
timer.timeout.connect(_on_timer_timeout)
add_child(timer)
func _process(delta):
rotation += angular_speed * delta
var velocity = Vector2.UP.rotated(rotation) * speed
position += velocity * delta
func _on_button_pressed():
set_process(not is_processing())
func _on_timer_timeout():
print("timeout")
visible = not visible
```
**URL to the documentation page (if already existing):**
https://docs.godotengine.org/en/latest/getting_started/step_by_step/signals.html
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.