Hi,
I’m new to save system, I’m trying to save materials that are changed at runtime.
Here, in my PC, I can drag&drop materials to components.
To retrieve these “changed” actors, I use tags.
Here’s my save event:
I think it works correctly, the print strings prints the right values, and the indexes from both actors and materials correspond.
Here’s the load event:
The issue comes from here.
If a load a save, only the first material is keep. I have the BP error: “Accessed none trying to read property CallFunc_Array_Get_Item_2” Node: Set Material
Here’s the print string result with 4 materials drop on 4 components:
If anyone can help…
If you’re going to use ADD, you need to clear the arrays before saving.
You’re just adding to the arrays in the save game every time.
I notice you do have some CLEAR commands, but then you don’t save it back to the save game.
Also, there’s absolutely no guarantee that getting actors of tag, or components will come in any specific order. It may be totally different after packaging, and be different every time you run it.
A much easier way to do this would be to make a blueprint that is aware when you change a material, and writes it to the save game. Each blueprint has an ID, it’s just an int.
On begin play, that blueprint finds it’s ID in the save game and loads what’s there.
1 Like
What do you mean by “aware when you change a material” ? And how do I do this ?
I will set something up, gimme a little while…
1 Like
Thank you!
For it to work, all the actors in my scene need to be in a BP with an ID ? because all actors in the scene can be material modified.
I’ve tried it with a Cube BP, with a slightly different setup since I drop material on actors without clicking on them. It kinda works, but it always says and saves the “Brick Bond Parquet” is on the actor, I must have made a mistake somewhere!
(EDIT: the Brick Bond is the first material in my DataTable which has the materials list, I don’t know if it’s linked)
the item comes from here:
Afraid I can’t see your mistake…
Yes, everything needs to be a blueprint. Which isn’t really much to ask if you’re going to be interacting with it.
MUCH easier than trying to code everything from the level BP.
– Can you show your code for ‘get save game’ also?
It probably has something to do with my drag&drop materials…
I have no idea!
When you give the material to the BP, it puts it in the SG, and reads it out again on begin play.
If you can make a condensed version of the level and put it in an empty project, I’ll take a look if you like, but I think you’ve just missed something somewhere.
1 Like
I’ll try to do that. Thank you!
1 Like
Ok, I see the problem. Your widget code is floating in another dimension from the cube blueprints
When you drag onto the cube, you have to tell the cube you change the material.
Hmm, it does trigger the cube, but all I know is, when I disconnect this, it stops working
Are these three thoughts in order ? Is there a solution to the problem?
Yes it stops because then this below isn’t powered anymore:
There’s code overriding what the cubes are doing, can’t find it yet.
Also, I changed this, to just ‘tell’ the cube what the new material is with an interface
in the cube
Update. Something is happening
There’s a material instance coming in here, not an actual material
It’s saving the material instance reference to the save game, which means nothing next time we start. Gimme a while
1 Like
Ok… ( phew )
I don’t know what really is going on with all your widgets and material instances and watnot, but …
So I just needed a way to say to the cube ‘This is your new material’. I did this with an interface:
In the cube
and in the cam controller
and the real material reference is coming from here
It works
I also stopped it whining about references to none, by disconnecting this
You’ve got your work cut out for you if you intend to change those dynamic material instances on the cube ( like UV tiling ), because you can’t save dynamic MI in the save game, because they are dynamic, like the name says.
If you want to do that, you have to always make the same material instances, and put them in an array and only refer to the array index in the save game.
That makes two of us!
This code is from the beginning when I really started blueprints on unreal, it was one of your colleagues here who helped me set it up.
I guess it could be improved, but I don’t know how! it does the job though.
Thank you for your time! To be continued…
1 Like
I forgot to ask about that.
Do you mean all instances must come from the same Material ? because it’s already the case.
So what you mean is I could put all instances in an array and save the latter in the save game ? I’m trying to understand the sweet world of save games…