About adding Blueprint Components during gameplay

Is there a way to add blueprint component form class, just like when you spawn an actor blueprint?

If there isn’t is it something that i can expect to be added in a later version of the engine?
(Also being able to properly use exposed variables with blueprint components would be nice.)

If both are out of the question, maybe someone have a suggestion for how i can handle this?:

What I’m using it for is; when a character in the game is affected by something, such as poison or is bleeding I add a blueprint component that will constantly deal damage to the player, the reason why I spawn a blueprint component is because one character can be affected by several damage over time events at one time so using a function doesn’t work, that’s why I went with blueprint components.
I kinda want to hear opinions, is there a smarter way to handle this and similar scenarios?

By damaging the actor/player, all you are doing is manipulating data. You don’t want to be spawning individual objects just to do this, it is highly inefficient.

-You might want to, for example, have 2 arrays (or a Map if you are working with C++)

-one array holds a value of “seconds remaining for this Damage-over-time”, one holds a “value of damage tick”
-Then every certain amount of time (every 1 second for example), decrease all values in the Time array by 1 and apply damage = the sum of all values of the second array

-When the value in the first array gets to 0, delete it that index from both arrays so that the damage corresponding to that entry will no longer be added

-On new damage applications you can either modify existing entries or add an entirely new entry to have DoTs stack

Let me know if you need more help

Using arrays never occurred to me, I like that idea!

Not sure how i would do this though, i have been brainstorming for a little bit now and I’m not sure how i would set up a system like that.
thanks allot for the suggestion!

Edit; I got it, but it doesn’t feel polished so I’m up for any suggestions :stuck_out_tongue:

You’d have a function like TickDOTS which iterates over the arrays and applies the proper damage while decrementing the “time” array by 1 every tick. If the time = 0 then you remove that entry from both arrays. You have a second function ApplyDOT which adds a duration into the Time array and adds a damage-per-tick into that second “damage” array.

NOTE: You must be VERY CAREFUL NOT to remove any entries from the array while you are iterating over it. If something gets down to zero time left, take a note of those entries and remove it after you loop over the array. Modifying an array length while you are looping over it will cause your program to crash.