Help with signal

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By josephbradley

I am trying to implement a brightness slider into my game but am running into problems connecting the signal.

A global function is called, which should emit a signal.

extends Node

signal change_brightness(val)

func update_brightness(value):
    emit_signal("change_brightness", value)

The function successfully prints the value so the error is not to do with this. The signal is connected to the below script.

extends WorldEnvironment

func _ready():
    GlobalSettings.connect("change_brightness", self, "_on_brightness_updated")

func _on_brightness_updated(value):
    environment.adjustment_brightness = value # sets new brightness value 

Hello is not being printed showing the signal is not working.


:bust_in_silhouette: Reply From: ponponyaya

Where you call function “update_brightness(value)”?
You should call the function in some where, otherwise it won’t work.

If you just want to check your custom signal is work, you can call the function after the signal connected in function “_ready”.