UFUNCTION() for getter defined in header

I have a getter function in my header MaximumTopSpinBall.h declared as such:

public:
        UFUNCTION(BlueprintCallable, Category = "PlayerHealth")
        float GetPlayerHealth() { return fCurrentHealth; }

But it’s throwing a compile error stating a semicolon is missing before the next declaration. When I add an extra semicolon to the end it compiles, but the function doesn’t show up in the blueprint. (It doesn’t show up even when I just type “player”.)

I think the code you placed in header file is conflicting with generated code. UHT assumes that you decler functions in header files and keep the code in cpp files.

I’ve moved it to my .cpp file, and it does seem to be compiling, but I’m still not seeing the function appear in my blueprint. As a method of AMaximumTopSpinBall, shouldn’t the function show up when I drag out that reference?

AMaximumTopSpinBall does inherit from APawn, so I don’t think there’s anything wrong with me casting it like this.

Do you see your function in Library under “Player Health” category?

You mean like right clicking and unchecking ‘context sensitive’ so it displays at the top: “All Possible Actions”? Because no, I’m not seeing it or the Player Health category in there.

Well, that took an annoyingly long amount of time to figure out.

Closing the project and reopening it caused the functions to show up. That’s all, just a reboot and the functions showed up. Compiling the code, the blueprint, reopening the blueprint, or even making an entirely new blueprint failed to make it show up when I tried earlier. I think I’ll submit a bug report after I finally make a bit of progress today.

Entirely new to C++ and had this issue as well. You’re fix was great though!

Shame that after all this time that hasn’t been addressed. But oh well…

Hi 8-lines,

I see that you’re encountering an issue where functions don’t appear to be usable in your Blueprints until you close the compiler and restart it. If this is correct, can you provide steps to reproduce this issue?

I created the same function used in the original poster’s example with no issue. Also, please be sure that you’re compiling in ‘Development Editor’ mode in the compiler you’re using. Not using this could require the editor to not be using the ‘Hot Reload’ feature which allows for it to update with newly compiled code.

If I can reproduce the issue, I can place the bug into our system and we can have it fixed as soon as possible.