Exporting normal variables works, but anything in a category or group will not update

Godot Version

Godot v4.5.1

Question

Hi there. I am having an issue where exported variables that are in groups or categories ( I have tried both) will not update, but any export variable that is standalone does update. Not sure if this is a bug or if I am doing something wrong. Once I get video upload privileges I can upload a video of the issue as well.

Thanks!

What do you mean by “update”?

So I am running the scene and wanting to tweak the settings of my character real time to get how they feel in game. I can modify exported variables and they take effect in the game, but any of the exported variables that are under a category or group do not change in real time

I may have found the issue, I don’t think it was an issue with me having an export variable in a group, but rather that the variable I am wanting to change is inside an @onready function, which if I understand right isn’t constantly recalculated?

@onready var jump_gravity := calculate_jump_gravity(jump_height, jump_time_to_peak)

Jump height was what I was attempting to mess with

It hasn’t anything to do with @onready either. If you initialize/assign something at declaration, the initialization expression will execute only once when the initialization happens. For vars declared as @onready in will happen just before _ready() is executed and for regular vars it’ll happen just before _init() is executed.

Okay, that makes sense why that value isn’t changing. I am guessing that means that if wanted to change these values in real time would it be best to have a function that periodically updates those values? An inelegant solution that I can think of off the top of my head is to have a timer that when it is finished recalculates my variables.

Also to make sure I have the concepts down, the reason a value like “@export var acceleration” changes is because that variable is used in a function that is called constantly while my game is running. Where the value that I was attempting to change to no avail, jump height, is because that one is used in a function that is only initialized once to define my variable “calculate_jump_gravity”

All variables that you declared as @export will change at runtime if you change them in the inspector. However, if there are other variables you initialized with those variables’ initial values, those won’t change. You need to update them every frame in _process() function if you want perpetual change.

@export var jump_height
@onready var jump_gravity := calculate_jump_gravity(jump_height, jump_time_to_peak)

jump_gravity will update only at startup with the initial value of jump_height, regardless of what you do to to jump_height afterwards in the inspector. Assignment does not create a link/reference, it just copies the current value.

So if you want constant update, you’ll need to explicitly do it every frame:

@export var jump_height
@onready var jump_gravity := calculate_jump_gravity(jump_height, jump_time_to_peak)

func _process(delta):
	jump_gravity = calculate_jump_gravity(jump_height, jump_time_to_peak)

There are also other mechanisms like setter functions that let you do updates only when variable’s value actually changes, as opposed to doing it every frame.

That makes perfect sense. Thank you for helping me with that! Would it be helpful to change the title to something along the lines of "Changing @export var in the inspector not changing @onready var values " since the initial title was just me not understanding fully what was going on?