What is the best method to set a variable to a weapon?

Based on the ShooterGame example project I am trying to switch one of the variables on the players weapon in-game via a box trigger. I have exposed the variables I want in C++ for the weapon and can quite happily trigger the changes in the actual WeapGun blueprint directly, however whenever I try to trigger those changes from outside of the WeapGun blueprint nothing happens.

I have tried using a custom event in the WeapGun blueprint fired off by a new variable referencing WeapGun_C in the triggers blueprint, but it does not seem to fire.

I presume it’s because the weapon is not physically spawned into the level as a separate object but is in the players hands? Which method should I be using to set the variable in the 2nd screenshot from outside of the weapon blueprint when it is the gun the player is carrying?

It is very possible you are referencing the wrong instance of the weapon class. Try this and see if it helps.

OnOverlap → From Other Actor → Cast to YourPawnContainingWeapon → If successful → Get Weapon from Pawn → Call Change Tail

You can also use Blueprint Interfaces to generalize the on overlap event.

Huge thanks Denny that worked perectly!

I am happy that I could be of assistance. Good luck in your future Blueprint endeavors!

Edit*
It seems my answer was accepted and then somehow unaccepted. Did something go wrong? :slight_smile:

Not at all! I think the title got edited by moderators so as to be more clear as to what I was wasking, perhaps that reset the accepted status? It’s still showing as accepted for me and resolved. Hope it is for you too now. Thanks again for the help :slight_smile:

It is indeed back to as it should be. Have fun Blueprintin’. :slight_smile:

Edit*
It seems as if my comment reply is causing the answer to be unaccepted. That’s incredibly weird. :smiley: