Can't get exported values to work in-game

Godot Version

4.22

Question

I’m trying to set up a basic enemies stats as exported values. However, when I print out the values they all show to be 0.

This is weird because i tested this on a small test object with a health value set up in the same way and it worked fine there.

Any idea why the values are not being set?


I FOUND THE PROBLEM:

Issue was that the enemy extended the class that did the stats logic and I didn’t delete the ready and process functions, thus overriding them with empty blocks of code.

1 Like

I believe the problem is you putting this in _init(), because _init is called before innitializing any values from the inspector, so when you set current_health = health, you are basically setting 0 = 0 before Godot does health = 100. Maybe you didn’t even need my answer, but here we go :smiley:

1 Like

Thanks for responding. Seems to work now with the logic still in _init() though :smiley:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.