Blueprint does not call my C++ Function property?
This is really confusing me for a while now so I decided to ask this question:
I have a character defining the following method in the header file:
And I have the following blueprint graph in my user widget:
When I toggle my UserWidget, the "Event Show" is fired. But the debug message "Called Get Inventory!" never appears on screen.
When I do an "IS VALID" test on the inventory retrieved from the character, it is always "INVALID". What am I doing wrong?
asked Apr 27 '17 at 10:17 PM in C++ Programming
It sounds like the character which has spawned in the level isn't actually a SurvivalCppCharacter so the cast is failing. Verify whether it is by getting the class of the character being returned by GetPlayerCharacter.
answered Apr 28 '17 at 12:11 AM
As Teiwaz said, its probably the cast isn't working.
Now if your game is a multiplayer one or has split screen, then the issue could be the way you are getting the player character. For user widgets you should be using the function from that class to get the player controller/pawn. This is called Get Owning Player Pawn.
You should also check the result of the cast. Have you tried putting a break point in your code to see if it getting hit? You can breakpoint the blueprint as well, and see the value of your cast to make sure it is set.
answered Apr 28 '17 at 01:27 AM
I would guess that you cannot make an inline function BlueprintCallable. Perhaps removing the FORCEINLINE helps. Also, I would consider making the function BlueprintPure, because it is only an accessor for data.
answered Apr 28 '17 at 10:47 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here