Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?

Product Version: UE 4.10
more ▼

asked Jan 23 '16 at 05:42 PM in Blueprint Scripting

avatar image

17 6 6 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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

more ▼

answered Jan 23 '16 at 06:22 PM

avatar image

160 10 12 19

avatar image Creamshake Jan 23 '16 at 06:56 PM

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 :P

avatar image HuntaKiller Jan 24 '16 at 05:32 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question