0 votes

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)
    print(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):
    print('hello')
    environment.adjustment_brightness = value # sets new brightness value 

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

Thanks

Godot version 3.4
in Engine by (14 points)

1 Answer

0 votes

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".

by (526 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.