Get Item By ID
Ok, so I want to make an item spawning system to make my life easier than individually placing the items in the world. I have assigned each item a Integer Variable called ID. Every item is a child of my BPMasterItem. I want the player to be able to type in the ID of the item and for it to be spawned. How would I go about searching for an ID equal to the input ID from only the master item? Is there like a ForEachChildren node or a way I can set something like it up?
Thanks in advance.
asked Feb 24 '18 at 10:41 AM in Blueprint Scripting
If you blueprint only then best way for you is to do it manual way, by simply making Integer to Class Map varable in some blueprint (GameMode for example) and manually assign integer IDs to Classes in varable defaults and they use them in spawning commands. You can use array if you don't plan to make gaps between ID numbers, but map is a lot easier to manage in property editor. Thats what best you can do in blueprint for what you want to make.
This is impossible to make it automatic in Blueprints because you need to use TObjectIterator to search all classes object (UClass objects) and then create array or integer map of classes based from BPMasterItem, which is long process and should be done on game start up possibly on game code module start up as it freeze up engine for a bit if you do that in main game thread. Alternatively trying to do something when Default Class Object of your classes is constructed which should be bit faster but that it still requires C++. Blueprint can't really do anything beyond world, not to mention look up for classes.
You would need to make create
Follow this question
Once you sign in you will be able to subscribe for any updates here