Detecting Enemies Using (For Each Loop) Not Working

So I’m trying to make an enemy that breaks apart when you look at them. I have been trying a couple ways to get this to work with moderate success but I now have a way to detect all visible enemies on my screen which stops working correctly when I cast to the enemy to break apart.

I start by getting all the actors that overlap with a vision cone that I created and attached to my FP camera. Then trace between the camera and enemy to see if I have a clear sight on the actor.

I then get all the actors hit in the trace and make an array so I can check if the hit actor has an “Enemy” tag. if it does I have a Line of sight on the enemy and it should then break apart. I’m doing this my casting to the Enemy_BP and making each part of the mesh fall off.

The issue I’m having is when I connect the Cast to Enemy_BP it stops detecting the enemies properly. I’m assuming its a problem with the custom event in the Enemy_BP but I don’t know what it could be

Is there a reason why you’re not using AIPerception component to detect if enemies are visible?

It might not work because you’re disabling collision.

I had messed around with pawn sensing but had no luck. You were right, Disabling the collision was bugging it out so I added a small delay to the custom event and it works as I expected it too now.