So im trying to just change one variable, and i dont seem to find a way.
At first i seemed to have found a solution, but when i reset the engine it breaks apart as you can see in the video.
Others have suggested to create a function that has a local variable for the struct, but i find that very clumsy.
So how do i change one or 2 variables that are inside a struct that comes from a data table?
It comes up with that error when it can’t find a UnitClass variable in UnitData. I would say try renaming UnitClass to something else and resaving it. Try to make sure there is no space in there. Might help.
You cannot change what’s in the data table, it’s static - and that’s what Set Member attempts here. Think of it as of default values for all your needs. Fetch a struct from the DT, feed it to the actor and the actor can modify that struct internally.
And you still have the original DT struct if you ever need it.
Others have suggested to create a function that has a local variable for the struct, but i find that very clumsy.
Changing the struct internally in the actor?
I tried that before, but was super clumsy.
I had to create extra variables and make them exposed on spawn in the actor just for that.
So that when i create the actor, it gets the struct and then it needs to check every single extra variable if they have any content.
Then overwrite the specific variables in the struct.
Its very messy.
But if thats the only way then, so be it.
Ah sorry. Because sometimes i need the variables overwritten and sometimes i dont need.
Think of it like:
You have your units.
But sometimes one of your units is the Captain.
So you need to set 2 variables inside that make him different than the other units.
In this case i need FName UnitUI = “Captain”;
And need FName FlagType = “Captain”;
Else i need it to be just a normal unit like the others, with the UI type being the normal type, and the FlagType being the normal.
Now imagine having to do that for all other cases…
Its much simpler to just edit the struct on the go…
Thanks a lot. I’m using inheritance for more complex stuff. Not for just one variable.
Im using inheritance for archers, and cavalry. Why? Because they have extra functionality.
But the difference between the captain and the normal units, is that it has a different flag and +1 attack. Thats it…
And every unit can be a Captain. See?
Its not really a separate thing.
But idk, and maybe im missing something, im not yet very experienced. Pls teach me, if im wrong.
It seems to me also that you created an extra struct just for the captain. Which maybe has a reason to be, but i see that as extra clutter.
Overall i try to avoid creating new files.
Isnt it good that its all the same class, and just changing one variable sets the new flag?