I have an Actor called BP_ItemBase. It contains a public exposed structure with name, description, type, etc. If I drag and drop the actor into my world, I can set all these information without any issues. Only problem is, that whenever I am reloading the game, those items obviously spawn back into the game. And the game in planning has lore items which you can only pick up a single time. Meaning I would have a flagging system which checks if the player has picked up said item in order to prevent the item from spawning in again. Well… that’s the theory at least.
First I thought I could spawn in these items with the Spawn Actor of Class node inside the Level Blueprint. However I couldn’t find a way to actually fill in the information provided by the public exposed structure if I’d use the Spawn Actor of Class function. Either it doesn’t exist or I couldn’t find a way yet.
Another theory would’ve been, to use the Level Blueprint, check the flag and then just use ‘Destroy Actor’ for this specific actor to just remove it from the map when loading back into the game. However I am very unexperienced with Level Blueprints and I have no idea how to get a reference to this specific item within the level to actually use said theory to destroy the actor if the flag checks out.
So far I only found articles and videos which would show how to use DataTables to set Actor Values. But that would mean I’d have to entirely re-do how the pick up system and storing works which would be a huge setback and these don’t answer my questions at all.
Growing a little desperate here and appreciate any help. Thanks in advance and have a great day!
EDIT:
I figured out how to get the reference now inside the Level Blueprint! That only leaves open my first part of the question: Is there a way to set actor attributes provided by a public exposed structure when using Spawn Actor of Class function.
Hey there! Thanks for your answer. My Save and Load System works perfectly fine. Just pretty new working with the Level Blueprint but I figured it out.
My initial question was basically, if I can set information to a spawned item.
I have an Actor called ItemBase. It has a Structure Variable (Exposed on Spawn, Instance Editable) in there. This structure contains of:
Name, Description, Icon, Static Mesh, ItemType (Enum), etc. Whenever I drag this actor into my scene, I can set all these information in the Details Panel of said item.
But if I want to use the Spawn Actor of Class function, spawning said ItemBase, how can I set the information? Does it just simply not work with this function or couldn’t I find the solution to it yet?
So you’d want to create a data table with the struct values listed above for each item, give the item class a data table row handle variable, that is exposed on spawn. Pass this to the actor from the spawning blueprint, then assign the variables on begin play to the item actor. I hope this makes sense and I’m understanding your need correctly, I use a similar approach with my enemy class spawn triggers. I can place them in the world in editor, assign a data table row, then at runtime it spawns actors of the enemy class according to what table row I set it to.
Hey there! Thank you so much for your answer. Is it only possible using a Data Table? Because I already have a Structure Variable being exposed on spawn within the item. How can it be that I can pass information if it’s made with Data Tables but not with a structure? Like, can’t I somehow assign the variables on Event Begin Play if it’s a structure?
I think I do understand your approach and I will try that out and do bit more researches about it. For now I will probably stick to just check the flags if the item has been picked up already and will destroy the actor on Event Begin Play.
Thank you very much once again and have a great day!
It’s be more efficient to just pass a reference to a data table row than an entire struct, alot less variables being passed. Either way could work I suppose but I’m not sure how you’d go about setting the stuct values at runtime, I’m not sure the engine will allow that. That’s why pre setting them in a data table, and just passing and calling the desired row is best as far as I know.