0 votes

How can I check if a variable was changed ?

Godot version 3.2.2
in Engine by (255 points)

2 Answers

+1 vote
Best answer

HI,

That's quite an open question.

Depends what you're doing and when you want to know when the variable was changed.

Maybe something like.....

Before a function:
Save the variable into a temp variable.
Do the function
Then check if the variable is different to the temp variable.

In a scene:
Save the variable to a temp variable in the ready function.
In the process function or a timer function check if the variable matches the temp variable, if they are different, call a signal or other function.

by (1,967 points)
selected by

ok thanks I think that should work but I thought there is a function or something else that gives a signal when the variable is changed.

yeah, there might be. Not sure.. :)

0 votes
by (240 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 webmaster@godotengine.org with your username.