I have tree actors placed in world from editor. I have option to chop them down, but on new game, they respawn, obviously.
I want to make them disappear on load game.
I tried, saving actor in an actor array, that I store in playerBP and on savegame save.
It works, for 4-7tress. If i chop down more, the array values become empty. Not really sure why it forgets entries so
inconsistent.
Also tried setting up tags for actor and On destroyed, saved the actors name in a string array.
And looped to find same names, but when i destroyed too many actors, i got infinite loop error.
I would avoid using “GetDisplayName” and use “GetObjectName” instead because instances generated at runtime might have different names. Unreal can also add extensions to names of actors in the world. If you have a tree object called “SM_Tree03” may become "SM_Tree03_355"at runtime.
To solve your problem, I would create a class with an exposed variable which allows you to disable trees.
Right click in your content browser and create a StaticMeshActor (or any actor type you need).
Call BP_MeshBase or a name which identifies that is a base class.
Open the MeshBase and create a variable called “bDestroyActorOnLoad” and add a branch check to destroy the actor on begin play…
On the variable “bDestroyActorOnLoad” make sure you check the following properties: “InstanceEditable” and “ExposeOnSpawn”