Does the console warning "Attempted to access index 0 from array" have negative Impacts on performance or on anything else?

Hello,

this is my first post on this forum, so please excuse me if there are mistakes.

To keep it short, i have been working on a mobile game for a while now and at some point i noticed that when you try to get an array index that does not exist inside of blueprints , you just get the default value. For example, doing get[0] on an empty int array returns 0.

I have used this to simplify blueprints, here is a small example:

At the start of the for each loop, the float arrays “baseDamageList” is empty. But in practice this still “works” because doing a get[0] on the first iteration just returns a 0 as mentioned above, so its still “aggregating” the values. This saves me from having to add an extra “if array length > 0” clause.

Now here is my question:
I have recently noticed,that when this happens, the output log throws the warning that is mentioned in the question title, but i am not quite sure what the consequences are. Since the code seems to work, are there any issues/risks I am causing here?

I have also recently ported my game to my phone as a test, and it seems to play in slow-motion (what should take 5 seconds in game takes about 6.5 seconds). I have still not found the root cause,do bad practices like these have any impact on the game performance?

In short, I’m hoping someone can tell me why i definitely shouldn’t do this and why, because from what i had seen so far, it works even though i get a warning thrown at me.

Many thanks in advance

It’s not a great idea to incorporate it as a coding ‘feature’ :slight_smile:

I’ve defintely seen others posting about array indexes causing problems in packaged games.

1 Like