# UE 4.27 - Saving all actors of a type and their locations

**URL:** <https://forums.unrealengine.com/t/ue-4-27-saving-all-actors-of-a-type-and-their-locations/1526324>\
**Category:** Blueprint\
**Tags:** unreal-engine, question\
**Created:** [December 14, 2023, 10:45pm UTC](https://forums.unrealengine.com/t/ue-4-27-saving-all-actors-of-a-type-and-their-locations/1526324 "2023-12-14T22:45:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bugbuh](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bugbuh](https://forums.unrealengine.com/u/Bugbuh)\
**Post date:** [December 14, 2023, 10:45pm UTC](https://forums.unrealengine.com/t/ue-4-27-saving-all-actors-of-a-type-and-their-locations/1526324/1 "2023-12-14T22:45:15Z")

</div>

Hello! I’ve been working on a first-person shooter game for a bit and have reached the point where I’m setting up the save/load system.

As enemy position is important in this game, I would like to be able to save the current ‘state’ (location, rotation) of all ‘Enemy’ actors in the level when you press the Save button, to be loaded when next you start from your save.

What is a good solution to this? I have a struct I will be using to store their relevant variables, but I am just not sure how to go about it.

Along with this, is there a simple way of storing your current level as a variable?

---

<div class="post-metadata">

**Author:** ![Mind-Brain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mind-brain/32/906573_2.png) [@Mind-Brain](https://forums.unrealengine.com/u/Mind-Brain)\
**Post date:** [December 14, 2023, 11:19pm UTC](https://forums.unrealengine.com/t/ue-4-27-saving-all-actors-of-a-type-and-their-locations/1526324/2 "2023-12-14T23:19:05Z")

</div>

Hey @Bugbuh!

So what you will want to save is the transform of the enemies. That’s Location, Rotation, and Scale as one variable, just to make it easy.

So you’ll use GetAllActorsOfClass (or any other methods of getting them as an array) then on a ForEach loop, in the body of the loop use a “GetTransform” for the actor and add THAT to an array(or you can use a map). This will get the indexes to match 1:1 on both arrays.

Then when loading, when you spawn each member of the Enemy class, you’ll pull the index on your spawning ForEach loop, and for each Enemy Actor, SetTransform using that array you saved and the index from the spawning Enemy!

Saving current level as a variable would be based on the name of the level- check this thread for instructions on that. 🙂

> [@How to store level as variable?,How to save current level as variable?](https://forums.unrealengine.com/t/how-to-store-level-as-variable-how-to-save-current-level-as-variable/447735/3):
>
> You can store your levels as an integer variable in an “actor object” you place in each level. If you name each level (map) something like “LevelX” where “X” is a number then you can simply create an array of your level names, and use a get node with an integer for the level to select and open whatever level the player is on based on the integer variable saved to a save game object. Similar to this setup.

---

<div class="post-metadata">

**Author:** ![Bugbuh](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bugbuh](https://forums.unrealengine.com/u/Bugbuh)\
**Post date:** [December 15, 2023, 12:11am UTC](https://forums.unrealengine.com/t/ue-4-27-saving-all-actors-of-a-type-and-their-locations/1526324/3 "2023-12-15T00:11:41Z")

</div>

Hello @Mind-Brain! Thank you so much for the response. Really appreciate your help last time.

Alright! I’ll give this a whirl. Thanks a ton!

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [January 14, 2024, 12:12am UTC](https://forums.unrealengine.com/t/ue-4-27-saving-all-actors-of-a-type-and-their-locations/1526324/4 "2024-01-14T00:12:24Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
