The best way to expose pointers to Blueprint

Hello. I’m new to unreal and would like to know how to properly expose pointers to BP. My pointer only works inside C++ and I’m starting to think there’s something I’m missing.

Are you sure currentPlayerAttacking is set in C++? You tried printing it out from there?

If so, then maybe you have multiple AttackManager instances spawned in the world and you’re checking the wrong one? Because “GetActorOfClass” will return the first instance it finds.

I have only one instance in the game, as shown in the print. I have even tested the get function inside attack manager class and it worked. The problem remains only outside of the class.

Maybe it makes sense to write a function outside the class? It’s just that when creating a function, do not specify the class attribute.

Sorry, I know how to use blueprints but I didn’t understand what you meant

What if instead of:


You used this:


Just trying to make sure you’re really accessing the same AttackManager instance with the getter method, as you do with the setter. Because I see no other way how the pointer could be null.

OMG, it worked! So silly error, thank you very much.

Actually after some tests I’m getting errors again, but this time is the opossite. I can access the player attaking in the UMG but not in the class anymore LOL. This thing is driving me nuts, it’s quite simple but nothing makes sense

So, I managed to find a turn around for the problem but did not find it. Maybe is something related to the class itself and the instance, since my attack inputs were binded to the class and the HUD was referencing the instance in the game.

So everything I had to do was change the binding from blueprint and get the actual class instance