Access C++ variable from blueprints?

Hi, I have a variable in my FPSCharacter.cpp class called “playerAmmo”. This is in my C++ code. Is it possible for me to access this variable from a blueprint? I want to make a HUD but I need to use blueprints instead of C++ code because I don’t know how to get the FPSCharacter instance of the character from a HUD class.

Never mind, I just made my ammo variables static and accessed them from the code. But I’m still wondering how to do this? I looked it up and I found this:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = “Ammo variables”)

Would that work? (Assuming I made maxAmmo a uint32 and not just an int).

Yes, using the UPROPERTY function you can access C++ variables from Blueprints. In this case in what be located in your FPSCharacter Blueprint.

2 Likes

Ah ok, thanks!