Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | KitePZ |
I have a button scene and main scene. Every X seconds an instance of the button (Bonus) is added to the main Scene. Whenever the button is pressed, it emits signal “bonus_pressed”. Except it doesn’t.
Here is the button code:
Bonus.gd
signal bonus_pressed
func _on_TouchScreenButton_pressed():
print("this one works!")
emit_signal("bonus_pressed")
Here is the main code:
Scene.gd
var Bonus = preload("res://Bonus.tscn")
func _on_TimerBonus_timeout():
var bonus = Bonus.instance()
add_child(bonus)
func _on_Bonus_bonus_pressed():
print("works as well!")
all the Godot signals are connected via editor and are connected correctly. Everything works as intended except the last function. If I place a button at main scene manually (in editor), then everything workes as it should, both messages are printed. However, when trying to press instanced buttons, only “this one works!” is printed.
Output:
--- Debugging process started ---
Godot Engine v3.5.2.stable.flathub.170ba337a - https://godotengine.org
OpenGL ES 3.0 Renderer: GeForce GT 630M/PCIe/SSE2
Async. shader compilation: OFF
this one works!
works as well!
this one works!
works as well!
this one works!
works as well!
this one works!
this one works!
this one works!
this one works!
this one works!
this one works!
--- Debugging process stopped ---