How to save an actor that is destroyed

I’m creating a survival game and right now i have the character destroy some tree’s however when i try to save i get errors of the destroyed tree(s) the error says it cant find it’s location, rotation, and scale. however when I use a print statement it tells me it’s location and rotation please help (the tree’s a procedurally generate). The game loads normally and the tree is destroyed and it saves the location of every other tree so why am i getting this error if it doesn’t spawn the tree anywhere on the map?

Can you include the code that spawns the trees and also the code that saves (the section that throws the error) :slight_smile: ?

If the actor is destoyed, thes it is (afaik) placed in a queue along with other non-used items that will be deleted after a certain amount of time. Therefore you cant access this object, as it is pending a kill, and therefore isn’t valid. If you need the trees transform, you can save this variable outside of this blueprint before the actor is destroyed.

This has my C++ code for the spawner and the blueprint where i am saving my game(in the pause menu)

i kinda understand what your saying but i save the tree’s as a class

So what I see is that you are going through every actor of class tree, and writing the transform to an array which is what gets added to your save game. But you’re saying that if a player breaks a tree, you get an error because it says it can’t find the location/rotation of the tree since it was destroyed? Can I see where you destroy a tree?

Why not just make the array. A array of all the trees which would also have their world location.

I destroy the tree in game/ so the tree’s spawn and then what i do is in game i have an actor hit with the projectile and the tree’s health is at 4 so when the actor is destroyed in the world and then i save it the error pops up
I destroy the tree’s in game. I am in the first person project and when the balls from the gun hit the tree 4 times the tree gets destroyed (i have a health value of the trees set to 4)

You can create a empty box for the tree location to spawn. Or you can take out destroying them. By doing something like making the mesh invis and have no more collision so you would still be able to access your array of locations and a timer to turn collsion and visibility back on wither on load or a timer

I set the collision off and the visibility off yet it still pops with the warning.

The tree’s do have their own location i just saved it as a class

I just saw in your first picture every time you save you are creating another save. You need to check if the slot exists and if not create then save if so just save. Have you looked at these arrays to see if they are actually being stored? And another big help if I can get a pic of the error log when you close.

This is what happens when i destroy 1 tree. What do you mean when you said i create another save??? and thank you so much for your help so far!

There is a node called does slot exist where you can branch. Because what is going to happen is every time you save. It is going to delete and recreate another save and reset all its variables. and access none usually comes from a broken reference. have you tried adding break points to make sure each tree can actually get the reference or any references are not getting correctly?

I do have all the saved objects print out their name, location, and there slot number. and when i used the save slot exists it pops as true.
and wouldn’t i want it to reset the previous save since there is only going to be one save slot??