Checking array in player blueprint event tick causes crash, what am I doing wrong?

I have an array that updates whenever the character is seen by AI Perception and works perfectly fine if i just print the length of the array (So if one enemy can see the player, it prints 1… etc) but im trying to check if it is empty (so no enemies can see) and if they can’t see then spawn another actor at the location. I have tried doing this but everytime an enemy sees the player, it crashes with this error:

Assertion failed: (Index >= 0) & (Index < ArrayNum) [File:D:\build++UE5\Sync\Engine\Source\Runtime\Core\Public\Containers\Array.h] [Line: 691] Array index out of bounds: 0 from an array of size 0

UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_UnrealEd
UnrealEditor_UnrealEd
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
kernel32
ntdll

I have also tried using array length = 0 but it does the same crash.

1 Like

Update: seems to be that removing that actor that spawns after a delay also causes the same crash so I’m gussing its the Destroy Actor that is the issue

1 Like

So you are attempting to access an array element that does not exist.
Your X >= 0 is TRUE if X is Zero. Try X> 0

1 Like

That maybe it. But the crash would still happen whenever i open the blueprint for the actor that was being spawned. The onlything in the blueprint is a skeletal mesh, nothing in the event graph

1 Like

Have you tried Is valid index node with a not boolean? If zero index is not valid, it is empty.

1 Like

This works, thank you! Also deleting and remaking the blueprint that was crashing when opening could have fixed it too :smile:

2 Likes

Glad it helped. Keep up the good work.

1 Like

I have the same problem but mine says bound 16 of size 16, where on earth do i start looking for this?? Please help

1 Like

can you show a print screen of your code and the error message?

1 Like

How do I find a line number to resolve a crash I am having, something is

Assertion failed: (Index >= 0) & (Index < ArrayNum) [File:D:\build++UE5\Sync\Engine\Source\Runtime\Core\Public\Containers\Array.h] [Line: 691] Array index out of bounds: 18 from an array of size 18

UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Core
UnrealEditor_Core
UnrealEditor_Core
UnrealEditor_RenderCore
UnrealEditor_RenderCore
UnrealEditor_Core
UnrealEditor_Core
kernel32
ntdll

1 Like

I know its a blueprint as i deleted all blueprints and it dissapeared.

1 Like

What was the last BP that you modified?
Also, a tip for you, keep you IDs confidential.

1 Like

Im not sure, ive not modified anything, unless its an auto update or something.

1 Like

When is this crash happening? During project start-up or when you try to play in editor? If is editor, try to ‘cook’ your content, so more messages and warnings will appear in the output log. Try to create a new topic to start a new conversation.

1 Like