I can't get my shop to work with the inventory system. Can someone help me? Here's what I have so far..
First off, thanks for the video, it was quite informative of your problem. I suspect you are right, the issue may lie with your HPPotionRef. The first thing would be to check if the HPPotionRef is valid. Pull off the node and type "IsValid" and put prints on the valid / invalid pins to see which one.
You can also check your logs for "Accessed None" warnings, which will read something like "Accessed none trying to property "HPPotionRef"...." If you see this warning, then the problem is with the reference. (Screenshot to show how to access the output log).
If the reference is valid, then it might be the struct itself not containing the correct information. You can "break" the struct and print out the data of your variables.
If everything comes out as it should, then the issue will most likely lie in your "AddToInventory" or "RefreshInventory functions. Let me know how the testing goes.
Good luck! :)
answered Mar 25 '19 at 11:38 PM
I am posting a new answer as I am suggesting a different approach. Essentially, all you need from your HPPotionRef is the information from the struct.
To do this you don't need to get a valid object from the world (which is what is failing in your application). I take it your information is present inside your HPPotion blueprint.
Change the type of your HPPotionRef to a class reference instead.
Compile the blueprint and then set the default value to reference your HPPoition class
Drag your HPPotion class reference into the event graph, pull off the purple pin and type "Get Class Defaults". You should see all your custom variables including your Item Info structure.
Place that Item info inside your "AddToInventory" function.
Now when I press the button in my example, it will print out the default values I have set in the HPHealth blueprint (in my example it's called BP_HealthPotion.
Remember for this method to work, the struct information MUST be set in the editor and not during runtime like so:
Try this approach, and see if it helps you along. Good luck!
answered Mar 27 '19 at 06:22 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here