• Godot Help
  • Godot 4 @export variables not updating as expected.

I am using Godot v4.0.2.stable.official [7a0977ce2] on an Apple M2 Mac mini running macOS Ventura 13.3.1.

This may be a bug, but I am not confident enough yet with Godot to assume it is.

The setup:
I am declaring 2 @export variables in the script attached to the main/top node of a scene. One is a float and the other an int. They show up and I can edit them as expected in the inspector.

The issue:
It took me a while to realize that changing the float in the inspector usually didn't actually translate into the code used when running the scene. I tried: making sure I always saved (cmd + s) before running a scene, stopping and starting the scene instead of the restart button, and even closing and reopening Godot completely. I never found a rhyme or reason as to why it usually didn't actually update and run the new float value in my scene - even though it shows the updated float in the inspector.

I came to find that the only consistent way to get the variable values to update when running the scene is to always change both values. This works every time I have tried. The problem is that this leads me to changing the int value, saving, running the scene, changing the int value back to the original, saving, and then re-running the scene just to get the new float value to work.

I am curious if I maybe misunderstand how variables work in the inspector, if they changed between G3 and G4, or if I am just experiencing a bug in G4.

I am more than happy to provide more screenshots and/or code, I just didn't want to bog this post down with too much fluff if this is just a bug in G4. I didn't find anything through searching the usual spots. Thank you!

variables in gdscript

values in inspector

After changing a property value in the Inspector, you need to press Tab or click in another field. Did you do that?

Apparently the change in the Inspector doesn't take effect until the field loses focus. I just tested this with 4.0.3-stable.

Godot 3.5.2 does not have this issue.

This is a reported bug:
Inspector doesn't confirm numeric field value change in Inspector on Save nor Run Project / Current Scene without pressing Enter nor exiting field #74557

    Yes, but I've learned the hard way that pressing Enter can be bad if the wrong thing is in focus.

    DaveTheCoder

    I guess it is caused by the very design of the controls, as in my game, it is also needed to press ENTER to force a textfield to accept changes made. I have this with various 4.0 releases: beta, RC or dev (last is 4.1-dev2).

    But it's a change in behavior from Godot 3. In that issue I linked, Calinou agrees that it's a bug.

    DaveTheCoder

    I feel a little silly that this was my issue, but you are correct. Tab, Enter/Return, and clicking outside of Inspector panel do the trick. I was clicking off, but not completely outside of the panel. Bug or not, it is very easy to adapt.

    Also, another great reason to have Output pulled up whenever possible. I sometimes forget that it prints a statement every time a value is changed.

    Thank you all for your help.

      gubco clicking outside of Inspector panel

      In my testing, it was sufficient to click in another field in the Inspector. I didn't need to click outside of the Inspector.