# Item Spawner BP giving Get Item Error?

**URL:** <https://forums.unrealengine.com/t/item-spawner-bp-giving-get-item-error/443318>\
**Category:** Blueprint\
**Tags:** get-all-actors-from-, spawning, unreal-engine, spawning-actors, Blueprint, question\
**Created:** [February 13, 2019, 3:37pm UTC](https://forums.unrealengine.com/t/item-spawner-bp-giving-get-item-error/443318 "2019-02-13T15:37:25Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deygus](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deygus/32/982675_2.png) [@Deygus](https://forums.unrealengine.com/u/Deygus)\
**Post date:** [February 13, 2019, 3:37pm UTC](https://forums.unrealengine.com/t/item-spawner-bp-giving-get-item-error/443318/1 "2019-02-13T15:37:25Z")

</div>

I am trying to create a blueprint that spawns items that fall from targets or box area in the sky above kinda so that the player can dodge them without being killed.

Basically, for extra game development/blueprinting practice, I just wanted to make a simple fun dodgy game for this on Android but for some reason, I am getting an error with my SpawnActor node and I cannot seem to figure out why in the world it is giving me errors even though it is working.

I followed this tutorial here [Blueprint Quickshot: Spawning Physics Actors | 04 | v4.7 Tutorial Series | Unreal Engine - YouTube](https://youtu.be/PpVfL2OhkmI) but, I have a BaseItem BP (master) with 4 children bp items that I am spawning randomly in an array that I connected and that seems to be the cause of it on the get node.

**Here’s the Error Message:**

 ![268478-2019-02-13-10h27-26.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/0/4/904372696e3a95ef646ddcd4dcfa2a7e15497bf1.png)

Also, is there a way to do this without it being on the level blueprint? I was stuck on that as well so I just put it there for now until I could figure it out.

Can someone point me in the right direction? I have been playing with it for a while and no idea how to resolve it yet.

**This is the prototype level:**

 ![268474-2019-02-13-10h26-22.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/9/9/99970b35602469f98aeed4c75e3dfb2b23a60a0d.png)

**These are the blueprints: Items in folder are just 4 children bp at the moment of the baseitem which is set as an abstract class so that only the 4 child objects are spawned.**

![268475-2019-02-13-10h26-28.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/7/b/f7be2da7d56a7410a53754eb01e9ca3b3245eb4c.png)

**Blueprint for Spawning Items with Targets on Level BP:**

 ![268476-2019-02-13-10h28-13.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/5/9/359e471deafa3f2401569f0dd88138f782c6fbf7.png)

**The Array for Child Objects in the BP:**

 ![268477-2019-02-13-10h28-47.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/9/4/a94948601ced66f470f9cffd57a45138bbe8eb7c.png)

---

<div class="post-metadata">

**Author:** ![Tuerer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tuerer/32/1008648_2.png) [@Tuerer](https://forums.unrealengine.com/u/Tuerer)\
**Post date:** [February 13, 2019, 3:45pm UTC](https://forums.unrealengine.com/t/item-spawner-bp-giving-get-item-error/443318/2 "2019-02-13T15:45:48Z")

</div>

Array indices go from 0 up, whereas Array Length counts as usual. So you have 5 elements with indices from 0 to 4, but you sometimes want to get 5, which doesn’t exits.

Make it Length - 1.

---

<div class="post-metadata">

**Author:** ![Deygus](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deygus/32/982675_2.png) [@Deygus](https://forums.unrealengine.com/u/Deygus)\
**Post date:** [February 13, 2019, 3:48pm UTC](https://forums.unrealengine.com/t/item-spawner-bp-giving-get-item-error/443318/3 "2019-02-13T15:48:22Z")

</div>

Okay yeah I know it starts at 0 for the counts, thanks for confirming that.

I think I understand, i’ll give that a try.

And do you mean " -1 " or " 1 " ?

---

<div class="post-metadata">

**Author:** ![Deygus](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deygus/32/982675_2.png) [@Deygus](https://forums.unrealengine.com/u/Deygus)\
**Post date:** [February 13, 2019, 3:53pm UTC](https://forums.unrealengine.com/t/item-spawner-bp-giving-get-item-error/443318/4 "2019-02-13T15:53:02Z")

</div>

Like this? Or?

 ![268479-2019-02-13-10h50-34.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/c/d/0cdb310d1692e91646ecafc6d043dabf86acbe51.png)

I just tried it but I still get an error for some reason:

 ![268480-2019-02-13-10h51-49.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/b/8/4b81c55fd7251d73d586f0b2a51ddfd2ff089c20.png)

---

<div class="post-metadata">

**Author:** ![Tuerer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tuerer/32/1008648_2.png) [@Tuerer](https://forums.unrealengine.com/u/Tuerer)\
**Post date:** [February 13, 2019, 4:03pm UTC](https://forums.unrealengine.com/t/item-spawner-bp-giving-get-item-error/443318/5 "2019-02-13T16:03:42Z")

</div>

Does it happen every time you want to spawn something or occasionally?

And Get Actors of Class requires minus one as well.

---

<div class="post-metadata">

**Author:** ![Deygus](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deygus/32/982675_2.png) [@Deygus](https://forums.unrealengine.com/u/Deygus)\
**Post date:** [February 13, 2019, 4:21pm UTC](https://forums.unrealengine.com/t/item-spawner-bp-giving-get-item-error/443318/6 "2019-02-13T16:21:41Z")

</div>

I added a - 1 int to the length above it for the other one and that seems to have solved the issue maybe. I will test again later after work, thanks.

Basically, what I want to do is remove the test F key I have in there and somehow replace it with a way to spawn the falling objects randomly over time so that they keep perodically falling but i’ll have to find another tutorial on it since idk how to do that part yet. I want that to get faster over time so that the game gets harder and harder while trying to dodge the falling objects.

It’s been done before by others I know and have seen but I wanted to use this for learning purposes mainly so I can advance to making more unique games.

 ![268493-2019-02-13-11h16-45.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/4/7/647e917748131d5b789b7d4851eef095069ab93d.png)

---

<div class="post-metadata">

**Author:** ![ThompsonN13](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ThompsonN13](https://forums.unrealengine.com/u/ThompsonN13)\
**Post date:** [February 13, 2019, 4:29pm UTC](https://forums.unrealengine.com/t/item-spawner-bp-giving-get-item-error/443318/7 "2019-02-13T16:29:22Z")

</div>

a little trick for you, instead of using length -1 just use the “last index” node. last index as one would guess gets the index number of the last member in the array, so it is basically length -1 but in one node.

---

<div class="post-metadata">

**Author:** ![Deygus](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deygus/32/982675_2.png) [@Deygus](https://forums.unrealengine.com/u/Deygus)\
**Post date:** [February 13, 2019, 4:31pm UTC](https://forums.unrealengine.com/t/item-spawner-bp-giving-get-item-error/443318/8 "2019-02-13T16:31:19Z")

</div>

Okay cool, thank you for the advice! 😃

---

<div class="post-metadata">

**Author:** ![Nebula\_Games\_Inc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nebula\_Games\_Inc](https://forums.unrealengine.com/u/Nebula_Games_Inc)\
**Post date:** [February 13, 2019, 5:48pm UTC](https://forums.unrealengine.com/t/item-spawner-bp-giving-get-item-error/443318/9 "2019-02-13T17:48:27Z")

</div>

An even trickier trick…just use “random int” it does all the work of subtracting 1 for you and gives you the “random int” you want 🙂

 ![268515-random-int.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/0/3/60383a5cfa0912c34837cca276a76df297438391.jpeg)

---

<div class="post-metadata">

**Author:** ![Deygus](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deygus/32/982675_2.png) [@Deygus](https://forums.unrealengine.com/u/Deygus)\
**Post date:** [February 13, 2019, 6:08pm UTC](https://forums.unrealengine.com/t/item-spawner-bp-giving-get-item-error/443318/10 "2019-02-13T18:08:55Z")

</div>

Ahh, that’s great to know, I never realized that. Thanks!
