Modify data asset during PIE and discard changes

Hello,

I’m creating a system that allows for upgrading arbitrary fields of a skill. for example, reduce cast time by %, increase damage by X, increase effect change by Y.

Skills are represented by data assets. My system has a UObject class that handles the upgrade and is accessing the skill’s data asset and changes its values.

When I stop PIE, the changes to the skill’s data asset remain. I want the changes to be effective only during a game session.

I know that in a packaged build it doesn’t work like that and the changes are reverted when the game restarts. I want this behavior in PIE as well, as it’s hard to playtest this system. Is there a way that doesn’t require keeping a custom asset holding the default values and manually rester them when the session ends?

Thanks!

I would highly recommend a layer between the data asset and the actual values used. Create a class that is able to load the data from the data asset. Than attach this object (eg a component) to the skill that need the information. Update that object, it has it’s own lifetime and you are free to do anything without messing around with the raw / default dataset. This will lead to very clean code aswelll which might come handy if you build up on it.

1 Like

Thank you for the reply!
Would you say that loading the data asset into a UObject that has the same fields (including the actor class to spawn), then changing the field on the UObject, and passing that object to the skill/projectile actor would be good? or did you mean something like a modifier component that would be added to the skill/projectile actor?

First case will work very well.

Create a struct “SkillStats” for the raw data. It has only data. Create a component “SkillComponent” (ActorComponent or SceneComponent). Now use the “SkillStats” as a property for “SkillComponent”. You can do something like “LoadStats” in the component or just pass a already loaded “SkillStats” parameter into that component, that’s free to you.

Attach the SkillComponent to any Actor. Then you can use functions from the “SkillableActor” or directly from the component. This component reads and updates the skill stats for that one object.

Maybe create another layer like “SkillableActor”, which always has a SkillComponent attached to it and expose the use of SkillComponent to the Actor.

2 Likes

Thank you very much.
My system includes global upgrades for skills so I’m gonna use a skill caster component on my character that will hold “upgrade structs” for all of the skills. the caster component will pass this struct to the casted skill and it will use its values to update its properties. because skills are spammable, I don’t want to keep creating the structs for each of them.
Thanks!