Item Spawner BP giving Get Item Error?

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 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:

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:

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

Blueprint for Spawning Items with Targets on Level BP:

The Array for Child Objects in the BP:

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.

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 " ?

Like this? Or?

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

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

And Get Actors of Class requires minus one as well.

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.

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.

Okay cool, thank you for the advice! :smiley:

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 :slight_smile:

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