The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

I have this tree:


On the singleton PartidaData I have a variable "camerazoom".
When the Camera zooms (animated with a Tween) it changes the value of that variable.
Locations take that value and gets visble/not visible according to that value.

The problem is that as Camera uses a Tween, Locations execute before it ends so doesn't work as espected.

This is the behaviour, if interested.

I thought about using a custom signal, but it feels hacky.

Godot version 3.4.2
in Engine by (46 points)

// use "group" //

extends Camera2D

  func example():
    if $Camera2D.zoom == Vector2(2,3):
        get_tree().call_group("group_name", "func_name")

or Use signal
signal = test

         func example():
           if $Camera2D.zoom == Vector2(2,3):

Ok will try it later. So I should call the group from the singleton you say?

1 Answer

+1 vote

Signal's not too hacky; this is a use case for that. Wait for something to happen, then respond to it. Just make sure your syntax is good.

If you go the "group" route like suggested above, you can call call_group from anywhere in the active scene tree since it's called on top of get_tree. Doesn't have to be in the singleton.

by (170 points)

thanks! I will go the group way, cause "Locations" is an abstract class and the subclasses will be called.

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.