I want to change the variable in another pawn when I click on the button.
I want to change the variable in another pawn when I click on the button. What to attach to object if I want it to be done when I press a certain button?
asked Mar 04 '18 at 01:13 PM in Blueprint Scripting
to change a variable on another pawn you need to get a reference to the other pawn. there are many ways to get a actor reference such as hit and overlap events, variables you set beforehand, and traces. once you have a reference to the actor you want to change the variable on you may need to cast to the actors class. then all you need to to do is get the variable then set it to the new value.
answered Mar 04 '18 at 04:18 PM
The fastest way is to use a "GetAllActorOfClass" and for each actor found you can set the value you want.
If the "StarGun_PU" is your main character you can pass "GetPlayerCharacter" as object. If the "StarGun_PU" is not your main character but is referenced in it, you can simply "GetPlayerCharacter", cast it to your Character class and then get the "StarGun_PU" reference from there.
Follow this question
Once you sign in you will be able to subscribe for any updates here