UE4 Check all Actors in an array for condition

So I have made this camera system that makes the camera follow a spline when your overlapping with the trigger box of the system. I also made it so that once you leave the trigger box it sets your camera back to is its starting location and rotation. That`s where the problem comes in, when I leave the trigger box of the system and right after I go back in the camera sets itself back to the start location for a sec and then it goes back the spline.

I dont want it to go back to its starting location if it detects that you went back in, so I made a branch. I also made an array with an object reference to the system, I can basically define witch system that I have placed in the world should be compatible with witch. The thing is I dont know how I can check all the indexes in the array for the same condition at once. I tried with GET array index but If there is nothing on that index and it tries to get it, it gives me an error. It works like this right now but as said I get a error that it can`t find something on that index.

Does anyone know what I could do?

Hello, could you provide a screen shot of the error and how you are making/setting the array? Also, can you show the setup you would be using when you are getting the error? I’m assuming you’d be using a ‘For Each’ loop.

Hey, so the thing is that I am not using any For Each loops. I can select witch system should be part of the array in the detail panel on the right when I select the system because I made the array in the Camerasystem_BP be instance editable. The only way I am setting the array is the picture I showed at the top. The error I get is saying that it cant get anything on the specific index because I haven`t assigned anything in the detail panel in the array on the index slot. Here are some pictures of the detail panel and error.

I hope you can kind of get what I mean.


It’s going to be hard to help if all you share are pieces.

Some question that might help us help you:

  • first thing is your title and the " I’m not using For each" comment do not go together…
  • You seem to have many instances that run this: are they all set up properly?
  • I see a delay node and a check overlap after: are you using tick to know when another actor overlaps? :face_with_monocle:
  • can we see the entire sequence that leads to the access none? From how is it triggered to the final node.

Yeah I’m having hard time understanding the full system which is making trouble shooting difficult. Probably adding a ‘Is Valid’ check from your ‘Get’ node will solve the error though since it looks like you’re setting the index 1 value is none.

From what I am understanding, you just wish to have all the objects that are preestablished to be acceptable objects (Compatible Systems) to be seen within a certain radius (Overlap).

In this is the case, you might be able to try a simpler method. Instead giving all the Compatible Systems a tag with the name Compatible systems. Then using a sphere volume on the viewport to check if an overlapped object has said tag.

Hey, I think you have something there but I already got the whole system working, I just get this error when I don`t fill out a slot in my array because clearly it cant get something that is empty, the error doesnt actually affect the gameplay but its just there witch is something I dont like that much.

Hey man, I am not using a For each loop. I am pretty new to UE4 so I dont really know how to use it to check all the actors in the array. I`m pretty sure that using it might fix my problem. But how could I do that with the For Each loop?

Because right now the System works, its just that when I Get Index(Lets say 0) and there is nothing in that array slot, it gives me the error. If I put the CameraSystem in the array slot instead it works but the problem is if I were to get more slots so I can make more of them compatible I would need to make more of these Get index nodes.

Imo This is the issue.

You are checking for indexes that do not exist.

You can:

  1. use for each loop: it will only check within the length of the array.
  2. Place is valid nodes after the Get.

Youll still ned is valid using for each, but its better if you plan to not have a fixed size for the array.

Set up this code in the blueprint that contains the Array variable

This is basically checking to see if anything is in the array to begin with. The contains not having a value is basically a NULL or blank.

If there is an index that is null, even if others are valid won’t this return true?

Maybe if checking length then is valid per index would be better in this case?

Hey man, yeah this is the issue that I have, also why I keep getting the errors. I am having trouble with figuring out how to do this the way you described. So you are saying I should drag off of each of the Get nodes and check if its valid right?
There are also two options when I type in IS VALID, which one should I take?
I am sorry for the dumb questions but I just want to make sure I do it right.

Better yet:

  • drag from the array node and select for each loop
  • from the for each use the is valid that is not pure (the one you can connect the execution pins).

Alright man that did it. Thanks to everyone for the help!

1 Like