0 votes

I have a parent class, that has an exported enum called type. I have some child classes that implement specific behaviours like CREATURE or SPELL each of which have around 100 children themselfs.
I recently wanted to add TRAP to the enum, but that broke everything, even though i took care not to change the older numbers assigned to the ENUM.

enum TYPE{
NONE = 0 ,
SPELL = 2,
FIELD = 4}

goes to

enum TYPE{
NONE = 0 ,
SPELL = 2,
FIELD = 4,
TRAP = 5}

Now every single child seems to be broken. While the editor shows the correct type, ingame every single scene is set to zero. I can confirm this with screenshots from the editor and the remote view of the scene in question. How do i fix this? Also how do i correctly update an ENUM without breaking already existing children?

Editor View

Remote view (Color Types is corecctly updated)

Godot version 3.5.1
in Engine by (15 points)
edited by

1 Answer

+1 vote
Best answer

I had that recently. You just need to reload project. However, if You updated the enum in a way it showed compillation error for too long, your exported values will be reset to 0 and You will have to set each of them back manually.
Generally whenever You change core variable, You have to make it quick, so the compiller doesn't report it as non-existing for a moment. If this would take too long, all inheriting classes will have their exported variables redone.
Also, whenever You update enum, You pretty much always have to reload project.

by (8,099 points)
selected by

Unfortunatly reloading does not solve the problem. I can set the values in the editor, but ingame every type enum is 0. Can i do anything to fix this? Maybe use a different version of the Godot? Also why is this even happening. I though everything the editor shows, is represented in the game.

OK, so after lots of debugging, turns out i had an onready var in my class, but i did most of the things before i added the nodes to the tree.

Regarding updating an ENUM, doing it quickly still seems kinda strange, doesn't it? But it works for now. Thanks for answering.

About doing it quickly :
I noticed, that after erasing variable from a script completely, compiller still remembers it. This feature must exist for purposes like changing a variable without needing to reentry every exported entry in every inheriting script. But if this memory is interrupted, all values are completely lost. I am not sure if time itslef interrupts this memory, but I suspect it is fragile and programmed to go away after some simple conditions are met.

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.