# Clear whole array(with items in it) using 'C' key and replace it with new items

**URL:** <https://forums.unrealengine.com/t/clear-whole-array-with-items-in-it-using-c-key-and-replace-it-with-new-items/474845>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [November 22, 2020, 2:56pm UTC](https://forums.unrealengine.com/t/clear-whole-array-with-items-in-it-using-c-key-and-replace-it-with-new-items/474845 "2020-11-22T14:56:14Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_4a6e9b29](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4a6e9b29](https://forums.unrealengine.com/u/anonymous_user_4a6e9b29)\
**Post date:** [November 22, 2020, 2:56pm UTC](https://forums.unrealengine.com/t/clear-whole-array-with-items-in-it-using-c-key-and-replace-it-with-new-items/474845/1 "2020-11-22T14:56:14Z")

</div>

![322762-i.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/3/2/532cdb39e6e447cd71efb4ef5a7905838a1e644f.jpeg)

Hi everyone  
The BP in the picture is from my spawner class, which contains array named “PickupType” with mine 4 pickup-items in it  
I also have a spawnpoint BP class - just a cube mesh, in which a random pickup-item from my array(PickupType), spawns. I have 2 spawnpoint cubes in my map - they spawn 2 random items from my 4total when I start the game.  
I want, when I am in the game and press C-key from my keyboard - the whole array to be cleared and when I press C-key again to be fill-ed with new random items, so that each time I hit C-key, all of the pickups on my map will change.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [November 22, 2020, 6:10pm UTC](https://forums.unrealengine.com/t/clear-whole-array-with-items-in-it-using-c-key-and-replace-it-with-new-items/474845/2 "2020-11-22T18:10:54Z")

</div>

This should do the trick:

 ![322777-screenshot-2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/c/9/0c9ebcbb040a4fbc38366d5a2e675eb58003cacc.jpeg)

][1]

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4a6e9b29](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4a6e9b29](https://forums.unrealengine.com/u/anonymous_user_4a6e9b29)\
**Post date:** [November 22, 2020, 7:06pm UTC](https://forums.unrealengine.com/t/clear-whole-array-with-items-in-it-using-c-key-and-replace-it-with-new-items/474845/3 "2020-11-22T19:06:43Z")

</div>

What is “Spawned Actors”, I do not have it ?

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [November 22, 2020, 7:09pm UTC](https://forums.unrealengine.com/t/clear-whole-array-with-items-in-it-using-c-key-and-replace-it-with-new-items/474845/4 "2020-11-22T19:09:32Z")

</div>

You make it. It’s an array of actors 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4a6e9b29](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4a6e9b29](https://forums.unrealengine.com/u/anonymous_user_4a6e9b29)\
**Post date:** [November 22, 2020, 7:21pm UTC](https://forums.unrealengine.com/t/clear-whole-array-with-items-in-it-using-c-key-and-replace-it-with-new-items/474845/5 "2020-11-22T19:21:24Z")

</div>

Sorry, but I do not get it. On my map I have - 1 spawner and 2 spawnpoint cubes - when I start the game these 2 cubes spawn two random items from my total three possible items . I add these 3 items to “pickup type” of my spawner

![322784-ty.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/2/3/523b1c0f4aa1cf43294e6fd65bc023c31410650b.png)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [November 22, 2020, 7:22pm UTC](https://forums.unrealengine.com/t/clear-whole-array-with-items-in-it-using-c-key-and-replace-it-with-new-items/474845/6 "2020-11-22T19:22:47Z")

</div>

That’s right, but if you copy the code it will work. Just make a new variable array of type actor…

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4a6e9b29](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4a6e9b29](https://forums.unrealengine.com/u/anonymous_user_4a6e9b29)\
**Post date:** [November 22, 2020, 7:35pm UTC](https://forums.unrealengine.com/t/clear-whole-array-with-items-in-it-using-c-key-and-replace-it-with-new-items/474845/7 "2020-11-22T19:35:15Z")

</div>

It’s different

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [November 22, 2020, 7:37pm UTC](https://forums.unrealengine.com/t/clear-whole-array-with-items-in-it-using-c-key-and-replace-it-with-new-items/474845/8 "2020-11-22T19:37:33Z")

</div>

It’s an array:

 ![322795-screenshot-3.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/2/9/229228721a4cc67286023baf90a90db2457e3617.jpeg)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4a6e9b29](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4a6e9b29](https://forums.unrealengine.com/u/anonymous_user_4a6e9b29)\
**Post date:** [November 22, 2020, 7:46pm UTC](https://forums.unrealengine.com/t/clear-whole-array-with-items-in-it-using-c-key-and-replace-it-with-new-items/474845/9 "2020-11-22T19:46:42Z")

</div>

I can’t connect these

 ![322787-222.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/3/7/937773f4cd97b0989c2491c1695946a44c6d5acb.png)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [November 22, 2020, 7:49pm UTC](https://forums.unrealengine.com/t/clear-whole-array-with-items-in-it-using-c-key-and-replace-it-with-new-items/474845/10 "2020-11-22T19:49:11Z")

</div>

make a new clear node by dragging from the spawned actors variable ( the other is not the same type )

( gettin’ there… 😉

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4a6e9b29](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4a6e9b29](https://forums.unrealengine.com/u/anonymous_user_4a6e9b29)\
**Post date:** [November 22, 2020, 7:59pm UTC](https://forums.unrealengine.com/t/clear-whole-array-with-items-in-it-using-c-key-and-replace-it-with-new-items/474845/11 "2020-11-22T19:59:22Z")

</div>

Thank you a lot for your help.  
I think I am almost ready, but I have 2 more questions.

1. What is “classes” and can I put “pickup type” instead
2. Where to put my 3 possible pickup-items- in spawned actors or pickup type ?

 ![322800-wh.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/1/8/b184014ab28176c1a9fe51765bba55449a62f871.png)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [November 22, 2020, 8:01pm UTC](https://forums.unrealengine.com/t/clear-whole-array-with-items-in-it-using-c-key-and-replace-it-with-new-items/474845/12 "2020-11-22T20:01:37Z")

</div>

Class IS supposed to be your pick up type array. Just put it in there…

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4a6e9b29](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4a6e9b29](https://forums.unrealengine.com/u/anonymous_user_4a6e9b29)\
**Post date:** [November 22, 2020, 8:15pm UTC](https://forums.unrealengine.com/t/clear-whole-array-with-items-in-it-using-c-key-and-replace-it-with-new-items/474845/13 "2020-11-22T20:15:40Z")

</div>

When I start the game my spawner spawns corectly, 2 random pickups in my 2 spawnpoints. But When I press C, nothing happends - the pickups stay the same  
This is all I do

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [November 22, 2020, 8:23pm UTC](https://forums.unrealengine.com/t/clear-whole-array-with-items-in-it-using-c-key-and-replace-it-with-new-items/474845/14 "2020-11-22T20:23:19Z")

</div>

Ok, need to check your blueprint. You need two things:

1 Input must be enabled:

 ![322802-screenshot-4.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/2/d/a2d900ebbcba321059404fa24e4faa2aa59845c4.jpeg)

2 Consume input must not be checked:

 ![322803-screenshot-5.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/5/a/45ad567fc10827d95c97aad7d3c1d558a4ddd426.jpeg)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4a6e9b29](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4a6e9b29](https://forums.unrealengine.com/u/anonymous_user_4a6e9b29)\
**Post date:** [November 22, 2020, 8:31pm UTC](https://forums.unrealengine.com/t/clear-whole-array-with-items-in-it-using-c-key-and-replace-it-with-new-items/474845/15 "2020-11-22T20:31:41Z")

</div>

There are not enough words to thank you all for your help. All things are working now.  
God bless you, and have a good day 🙂

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [November 22, 2020, 8:39pm UTC](https://forums.unrealengine.com/t/clear-whole-array-with-items-in-it-using-c-key-and-replace-it-with-new-items/474845/16 "2020-11-22T20:39:57Z")

</div>

Excellent 🙂
