Change Actor‘s default value of the variable on game runing.

hey,guys, I would like to ask a question.
I have a soldier actor.it has a AttackDamage variable,it’s default value = 5.
I want to implement a feature:
when i downclick the button.all soldier’s AttackDamage = 10,and spawned soldiers also have 10 attack damage.
I’ve tried passing 10 in either the beginplay or constructor, but that would require you to get the number 10 every time a soldier is spawned.
I’d prefer to change the value of an actor blueprint , just like I would change the value of an actor blueprint in the UEeditor.

You will need to make some kind of global variables with a function get/set.

For example, if it an RTS game, you could create a MAP variable like below in your player character/controler:

Then from your widget button, OnClicked > Get PlayerChar/Controller > Cast > Call Set that variable.
With you actor solder attack event > get that variable value.

Thank you for your reply.
Do you mean to store attack damage in one place and then have all the soldiers get that value?

Yup with some form of filter/type of soldiers.

ok, thank you .

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.