# Destroying one actor with multiple copies

**URL:** <https://forums.unrealengine.com/t/destroying-one-actor-with-multiple-copies/1694120>\
**Category:** Blueprint\
**Tags:** coding, unreal-engine, Blueprint, question\
**Created:** [February 17, 2024, 2:53am UTC](https://forums.unrealengine.com/t/destroying-one-actor-with-multiple-copies/1694120 "2024-02-17T02:53:13Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ItsssYucky](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ItsssYucky](https://forums.unrealengine.com/u/ItsssYucky)\
**Post date:** [February 17, 2024, 2:53am UTC](https://forums.unrealengine.com/t/destroying-one-actor-with-multiple-copies/1694120/1 "2024-02-17T02:53:13Z")

</div>

Hey,

I am trying to make an ability in my game where you can spawn in three of an object and when you spawn in the forth, it automatically deletes the first, and so on and so forth. Currently, I am able to delete one. However, after I get the error “Blueprint Runtime Error: “Attempted to access BP\_SpawnablePlatform\_C\_1 via property SpawnablePlatRef, but BP\_SpawnablePlatform\_C\_1 is not valid (pending kill or garbage)”. Node: Destroy Actor Graph: Spawn Platform Function: Spawn Platform Blueprint: BP\_FirstPersonCharacter”. I figure this is because the call to destroy actor does not know what to target but I was wondering if there is a way to fix this.

Here is a photo:

 ![2024-02-16](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/3/9/e3937296bcbc752749d228bc0ebc5c33c98f7bee.png)

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [February 17, 2024, 4:53am UTC](https://forums.unrealengine.com/t/destroying-one-actor-with-multiple-copies/1694120/2 "2024-02-17T04:53:58Z")

</div>

add your platforms to an array, when its full (length = 3 platforms) get index 0, destroy actor, remove index 0.

this will remove the first platform and add the latest one last

---

<div class="post-metadata">

**Author:** ![ItsssYucky](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ItsssYucky](https://forums.unrealengine.com/u/ItsssYucky)\
**Post date:** [February 17, 2024, 7:55am UTC](https://forums.unrealengine.com/t/destroying-one-actor-with-multiple-copies/1694120/3 "2024-02-17T07:55:11Z")

</div>

I am sorry. I am pretty new to unreal and have never used arrays. Could you explain how to do this? I made an object array and made 3 indexs with each one being a refrence to bP\_spawnable platform, but I get the feeling this was incorrect.

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [February 17, 2024, 10:52am UTC](https://forums.unrealengine.com/t/destroying-one-actor-with-multiple-copies/1694120/4 "2024-02-17T10:52:10Z")

</div>

you dont need to add index’s, just grab the array and use the add node.  
the array should be of type actor so you can use the destroy actor node on it later.

encapsulate the pseudo code above to remove the first platform.

if you need more help show me your code so i know exactly where you are at

---

<div class="post-metadata">

**Author:** ![ItsssYucky](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ItsssYucky](https://forums.unrealengine.com/u/ItsssYucky)\
**Post date:** [February 17, 2024, 11:00am UTC](https://forums.unrealengine.com/t/destroying-one-actor-with-multiple-copies/1694120/5 "2024-02-17T11:00:06Z")

</div>

Alright, I will try it in the morning and let you know.

---

<div class="post-metadata">

**Author:** ![ItsssYucky](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ItsssYucky](https://forums.unrealengine.com/u/ItsssYucky)\
**Post date:** [February 17, 2024, 7:36pm UTC](https://forums.unrealengine.com/t/destroying-one-actor-with-multiple-copies/1694120/6 "2024-02-17T19:36:24Z")

</div>

I’ve been working on it but don’t fully get it. I have to go to work so I’ll try later today or early tomorrow and get back to you. Sorry about all the delays.

---

<div class="post-metadata">

**Author:** ![ItsssYucky](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ItsssYucky](https://forums.unrealengine.com/u/ItsssYucky)\
**Post date:** [February 18, 2024, 7:20am UTC](https://forums.unrealengine.com/t/destroying-one-actor-with-multiple-copies/1694120/7 "2024-02-18T07:20:55Z")

</div>

So it seems to be working but I am getting the error: Blueprint Runtime Error: “Accessed None trying to read property CallFunc\_Array\_Get\_Item”. Node: Destroy Actor Graph: EventGraph Function: Execute Ubergraph BP First Person Character Blueprint: BP\_FirstPersonCharacter. I know it has to do with the fact that index 0 is empty at the start, but I am not sure how to fix it because everything seems to be working other than that. Here is the graph below:

 ![2024-02-17 (3)](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/7/6/776650c87607fe7471b45d559a6d19c038366760.png)

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [February 18, 2024, 7:24am UTC](https://forums.unrealengine.com/t/destroying-one-actor-with-multiple-copies/1694120/8 "2024-02-18T07:24:54Z")

</div>

well you only want to destroy a platform when its full right?

full defined by you as X platforms

so before you call DestroyPlatform check if the length of the array = whatever X is for you

---

<div class="post-metadata">

**Author:** ![ItsssYucky](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ItsssYucky](https://forums.unrealengine.com/u/ItsssYucky)\
**Post date:** [February 18, 2024, 7:26am UTC](https://forums.unrealengine.com/t/destroying-one-actor-with-multiple-copies/1694120/9 "2024-02-18T07:26:58Z")

</div>

Yeah, I’m doing that right before I call the action here:

 ![2024-02-17 (4)](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/8/4/e84a83a6d65054ee164358b755b00a525eeb89af.png)

The platforms are deleting themselves properly but I’m getting the error code form above.

---

<div class="post-metadata">

**Author:** ![ItsssYucky](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ItsssYucky](https://forums.unrealengine.com/u/ItsssYucky)\
**Post date:** [February 18, 2024, 7:41am UTC](https://forums.unrealengine.com/t/destroying-one-actor-with-multiple-copies/1694120/10 "2024-02-18T07:41:56Z")

</div>

I just fixed it. I was being dumb. Thank you so much for the help.
