Topic was automatically imported from the old Question2Answer platform.
Asked By
SIsilicon
I am building an add-on that requires the editor’s camera. Using position every frame made the result I want look laggy. So I figured that I could use a signal that activates every time the camera’s transform changes. There is a notification called NOTIFICATION_TRANSFORM_CHANGED. I thought could somehow use notifications with signals. But how?
You can use the _notification() function present in both Godot 3 & 4 and a few other steps to achieve what you want.
I believe you have to use set_notify_transform(enable: bool) with enable set to true to be able to receive the NOTIFICATION_TRANSFORM_CHANGED notification.
Here’s the code that I found that works to do this:
signal camera_has_transformed(new_position)
func _ready():
set_notify_transform(true)
func _notification(what: int):
if what == NOTIFICATION_TRANSFORM_CHANGED:
emit_signal(“camera_has_transformed”, camera.global_position)
Apologies for being 5 years late, but I hope this helps anyone else in the future. Here’s some more documentation regarding it if you need it (which is where I just learnt this from) . This code should work regardless of using Godot 3/4.