Godot Version
4.2.1.stable.mono
Question
I am trying to make a very well organized “Player Variables” section in the inspector of my player scene in my game. It should be structured like this:
-
Grounded Movement (group)
- Instant Grounded Movement (boolean)
- some more variables
-
Air Movement (group)
- Instant Air Movement (boolean)
- some more variables
The Instant Grounded Movement
variable, when toggled on, should make the other variables in the Grounded Movement group after it disappear (same thing for Instant Air Movement
). To do this I override _get_property_list()
and return an Array of Dictionaries that represent the variables that might be hidden or not depending on the state of Instant Grounded movement
. This works pretty well until now but I have encountered a problem that can easily be described in the following image:
In _get_property_list()
I put all the variables inside of a category called “Player Variables” because otherwise it doesn’t look good. I also put Instant Grounded movement
in a category of the same name but it is exported using @export
annotation and it does not show up in the same category. I would very much like to export Instant Grounded movement
using _get_property_list()
but there needs to be a setter function for this variable and I do not know how do that!
Here’s my Instant Grounded movement
variable:
@export var instant_grounded_movemement: bool = false:
set(value):
instant_grounded_movemement = value
notify_property_list_changed()
Summing up the question
How do I export a variable using _get_property_list()
and make it so that variable has a setter function that gets called every time it gets changed through the editor?
Thanks a lot to anyone who would give me advice on this!