Can you tell me how I am being dumb?

Hi,

So obviously I am being dumb and missing something here.

I have a datable with 2 items in, (as a test, there will be several more in the end) I transfer those items to an Array. (so that I can pick and sort the items I want) I have printed a string of the array length and there are 2 items in it. I then loop through that array with a for each loop and say Spawn Actor. ( have attached a print string to the loop and it says 0, 1 so only has 2 items in it)

So looking at that I should have spawned 2 actors, right!? However in another piece of code I use the function get all actors of class and ask it to spawn a widget to be added to a uniform grid. When the game loads there are 3 items in my array 3!!! and only 2 of them have the data from the data table…the other is an empty blank widget.

So what am I missing?..I am no doubt being dumb somewhere but I have printed strings and tested all my arrays, they only have 2 items so should only create 2 actors.

I did some further testing where I had 0 items in my array and it still created an actor, but still never gave it any data. So it seems like the “get all actors” function is returning a phantom creation.

I ran some another test where I didn’t do a for each loop and used a loop, and set the range from 1-2 trying to avoid the erroneous 0 spot in the array, however instead of the expected 2 items I got 1 blank item and 1 full. I then just did get point 2 in the array and it returned a blank item.

When I run the thing, in the world out line there are 3 actors…I just don’t understand where the third actor is coming from? I am using a “for each loop” on an array with 2 items in it. More bizarre than that though…it doesn’t complete the code…so I have 1 blank and 2 filled widgets…so it is creating an actor and then stopping without running the entire line of code…and then running through 2 times and creating the code correctly.

I have never seen anything like it and it is blowing my mind! I thought maybe I am creating an actor in another line of code somewhere…but that would not be creating a widget, so it wouldn’t appear on the screen.

My mind is boggled after looking at this 1 small thing for 2 days…help me internet, you are my only hope!

Thanks

first check you don’t have an instance in your map somewhere (took me hours to spot in mine as it was in a sub lvl).

Second I had a similar situation and had to put an is index = 0 if true do nothing on the for eachand then populate all arrays being used like that with 1blank entry

If the second works then there’s a issue with the data table referencing no.s

first check you don’t have an instance
in your map somewhere (took me hours
to spot in mine as it was in a sub
lvl)

This. Happened too many times. I remember counting widgets and forgetting about the ones created by widget components…

Lol yeah I had an old spawn system spawning 1 widget from a 0entity in a non visible sub lvl nearly broke me.

The only assumption I can make is that I am creating something somewhere…but I have looked through the the world outliner and there is nothing…I can’t see anything in my level it is at the moment only about 5 box brushes, as it is a test level.

I did a search on ALL blueprints looking for the “spawn actor” node and it only found the one I know about.

I probably am spawning it somewhere else like a fool, but I did something similar to you as a fix for the time being and just did an in int in range and started at 1 instead of 0. It solved the issue, but I now have a use for the get all actors node again…and keep skipping the 0 entry is tiresome.

I’ll keep searching! Thanks for your help.

perhaps when looping through all the actors of class print the display name of the actor, see if that clears anything up.

That suggested that your data entry line 1 is sitting as a 1 instead of a 0.

As a debug option … before you Loop spawn, get all actors of class → loop → destroy actor.

From there you know for fact there are zero actors of class in the level. If you still get the 3 actors later down the line you know the problem lies elsewhere.