Need help understanding how to access variables in ue4 c++

It all depends on your system and what type of game you want to make but here are two suggestions

  • On your weapon class, create a variable that references the owner of the weapon, for example an ACharacter* owner variable, (you could use your custom character class too). Then whenever you create this weapon you set the owner variable so it points to your character.
  • Use the actor iterator if there’s only one player. You could iterate while looking for a specific class (yout character class), this way you can find the referece for any actor you want, in almost any part of your code.

Here’s a link that explains actor iterators

Hope this helps!