What is the proper way for child classes and exposed variables.

I am having a hell of a time with child classes in blueprints. So I think I have the wrong idea on how blueprint child classes work.

I have a parent enemy class. It has a ton of events for moving, attacking and things like that. It also has a bunch of exposed variables, like health, hidden, isChasing.

I dont use that parent class ever, but I do make alot of edits to it. I have child classes of that with a shooting type enemy, boss type enemy, swordsman type enemy, all with different default settings to the exposed variables of the parent class.

The parent class also has default animations because most of the enemies use the same mesh.

I place multiple different enemies. I change the different variables that are exposed while placing them on the level, like its health, or is it chasing the player right away.

The problem is, every time I make an edit to the parent class, it changes everything on the child classes. If i compile the parent class one time, sometimes (usually after i restart my engine) all my child classes animations are re-changed to the parent class, all there health is changed back to default 5, every exposed variable I manually inputted while placing the the actor on the level is back to the default of the parent class. Even when I change the variables inside the child class blueprint, they get change back to the parent class.

The only thing I can think of so far, is for every child class, have a constructor with new variables specific to only that child that set the parent variables.

The idea is correct and the issue is something i’m also experiencing. I have LevelNodes for an Overworld level and the Child Classes that i placed in the world suddenly reset to the default
values of the Parent. But i get this even then not changing the Parent Class, but more like randomly (couldn’t find the cause yet).

I think it’s the same problem, so i leave you my AnswerHUB post here, to check if Rudy and I can find a solution:

Do your children classes SET the values, or do you just set the default and save? I think by default I have always had my event construct SET values for that class.

I, for myself, did make them Editable, placed a few in the Map and changed the values of the placed ones and these do reset, like said above.

And i sounded like he experiences the same.

Yeah. I have them exposed. The either set them inside the child blueprints defaults where you can see the exposed variables of the parent. If I was not doing that I would set them while placing them in the world. For example, i might scale a guy to 1.2 times the normal size, so I might set his heath to 7 instead of 5. Later on, all those values are back to default, but the scale remains the same because that was not an exposed variable from the parent.

I am getting around this by making MANY different child classes for every scenario, and having variables in the constructor setting the parent variables…pain in the *** but at least I can finish my project.