I’m looking to spawn and remove saved actors in the level at runtime. I’ve come to road block where I can’t seem to find any mechanism for determining the actual object type that is being save/loaded via blueprint. I would like to use the asset path and load it. I’ve figured that part out except for getting the actual object asset path at runtime via blueprint. Any help would be much appreciated.
You need:
Ok. If you’re trying to look at the path just to spawn and remove actors, then you probably are going about it the wrong way.
The usual way would be using:
and then get rid of it later with:
Like that?
I think this is what i am looking for but I can’t seem to get my actors/components to spawn anymore. I may not have been doing it correctly in the first place. You wouldn’t by chance know how to use this path to get an object to spawn would you?
I’m actually looking for a way to handle user generated content. A player will be able to build their ship by adding components to it at runtime. I need to be able to load and unload the ship at runtime as well. I figured I could just use the path of the asset (component/actor) to save and use to reconstruct the components of the players ship when it’s loaded in.
In a word ‘no’ Don’t do it.
You will defintely come into a world of pain if you try and do it that way. The only time you should be looking at the pathnames of assets is if you’re writing an asset management system.
The correct way to do this is using the savegame object. It’s just a BP which contains variables which you can write to a file ( you don’t need to know where that file is ) during gameplay.
Here’s a tuut:
So your ship will either be one BP, or many. And those BPs take their configuration and visible components etc from the save game variables.Tell me if you need more info
That doesn’t allow for the saving of component references though, does it? For instance, say that the players adds 8 bp_ThrusterEngineComponents to their ship, which is an actor. Correct me if i am wrong but I would need to create a struct blueprint for for every object that I want to save and then make sure that the ship struct had an array for each ship component that can be added to it.
What I am currently looking at is using the asset manager and making my savable components primary assets. That way I can use the asset manager and primary asset id to load assets and create references without needing the know the exact type at loadtime other than assuming that it inherits an interface blueprint used for ship/component interaction.
Yes, that’s right, but recording path name is not the answer.
To be clear, it’s totally up to you
Let’s say during the game someone attached 8 thrusters to their ship. You record this in the save game. Then when play restarts ( the next day or whatever ) you load the game and give the 8 thrusters again, they wont even notice.
All the thrusters have new object references, but it doesn’t matter.
( a bit more ), no you don’t have to make a BP for everything, you can just attach an instance of a actor to the ship, just like you do currently, you just re-do it when the game re-starts.
I was originally going to do that but but a single ship could have hundreds or even thousands of components. I want to avoid the overhead that an actor adds.
I don’t need the reference at all. I just need a way store and retrieve the particular type that it is so I know what to spawn when it is loaded. I’m looking to do this in a way that I don’t have to manually create a map and add the key/value and have each type have a reference to it’s types key.
Whatever structures ( in the general sense ) you make to construct the ship during play, just make sure you save enough info so the ship can be re-made automatically on game load.