How to get all actors of class separately?

I have a truck BP spawning in an array “say 5 are spawning” in random places. The truck BP has an arrow component behind it. I have a main camera fixed in the world. When you event click the truck the camera moves to the location and rotation of the arrow component. The problem I’m having is, no matter how many I spawn when i click the truck it only moves to one. So if click a different one it still moves to the same one again and again 'if that makes sense". I’m trying to get each BP’s variables, arrow, and other components separately after they are spawned in an array. Getting all actors from class isn’t working in my level BP, and I’m using All actors from class on level BP, casting to truck BP, then getting arrow. I’ve tried get array, get length, cast afterget array index, everything.

Well that should work. So it looks like that there is something wrong with the selection of your Truck. How do you select the clicked truck? Because it seems that this always returns the first truck in your array. Actually for that your don’t need the array at all. In your controller just use a “Get Hit result under cursor by Channel” (switch channel to camera for BP selection…I don’t know why this is needed but “Visibile” isn’t working for me), “Break Hit Result” and cast the Hit Actor to your Truck BP. If cast is ok, do the rest. For a visible reference you can also add a “Get Display Name” on the Break Hit Results “Hit Component” Pin and print this to screen. You should get a print out like “…truck_01…”, “…truck_02”…etc…

Best regards,

The truck BP has the click event in it. So truck is in world and when clicked it moves in. So I guess its finding the collision of box component of the truck to handle the event. I am able to get all other variables when clicked because the variables show up in my HUD for each truck. Its just this moving a camera in world to the arrow position.

As said, check if your camera movement finds the correct Truck to move to. It looks like it is not finding the “selected” (or how you have implemented it) truck.

I’m still having no luck with this, any way you or anybody could post a pic of a setup? My trucks are spawning at runtime, and my click event is in truck BP. So when they are spawned i should be able to click each one separately for the camera to move to. No matter what combination I try it still only moves camera to last picked truck in array when clicked. I also have a button that moves the truck in certain directions once selected. That also is only working with last truck in array. Even when picking different truck still only moves that one. HELP!! LOL

Cant post a setup because I’m not working on it and I dont fully understand what you are doing. Would be better if you post what you have. Or if you cant upload the project. I’m sure its something easy. If you have a logic to switch the camera to the selected truck I guess it is just selecting the wrong one…