Help with signals between scenes

Godot Version

4.2 web
i need help with some code

func _on_timer_light_colour_animations_animation_finished(anim_name):
if anim_name == “day to night”:
emit_signal(“turnednight”)

if anim_name == "night to day":
	emit_signal("turnedday")

this comes from my world root node called world i have tested and the animation stuff work fine

    $world.connect("turnedday", itday)
$world.connect("turnednight", itnight)

i then have this in a diffrent scene the $world is current there but is a varient of diffrent things. world is autoloaded rn and i have tried world. but still nothing

func itday():
$damageable.health / 2

func itnight():
emit_signal(“jumpleft”)

$damageable.health * 2

i then have this in the same script. the jump left is to test if it goes through and it doesnt

idk whats going wrong i have spent a total of 5 hours trialing and resurching but idk.

Can you enclose your code inside “preformatted text” blocks so it is easier to read?

You can also just enclose it with triple backquotes.

It is difficult to help because your code snippets are so incomplete. In which script are you trying to connect your signals? Where are you declaring your signals?

signal turnedday

When I get stuck like this I create a test scene in a test folder. In that test folder I try to create a minimum code example of what I am trying to do. Here you seem to be trying to create a signal and connect to it from a singleton called ‘World’. You could do that in just a few lines. Once it is working in the test folder, you can then follow your implementation through in your actual game code and compare them. Usually doing this process reveals the source of the problem.

Not specific I know, sorry, but I hope it helps.

PS Stepping through your code using the editor tools is pretty powerful too. Or use some print statements to say “signal sent” or “signal received” in relevant parts. This can help debug quickly too.

1 Like

yea i tried the debuging methods before but i couldnt pin point the issue but the tip with issolation folder helped and i managed to get it. to be clear i didnt firgure out how to do the original things but i found an alternate way that isnt too much worse. illl look into the main thing in an folder more later. thanks

1 Like

Do you use a signal manager? (Some people call it a Signal Bus). Just an autoload that contains all your signals. Since I started using one keeping track of signals has become so much easier for me.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.