Checking how many actors of the same class are overlapping

Hello all,

I’m working on a project where the player can remove parts of the scene. The parts of the scene that the player can alter is made up of a multitude of ‘block-like’ components which have a triggerbox just slightly larger than the mesh. What I’m trying to accomplish is that if one of these blocks finds itself with no other block components in it’s trigger box, physics are enabled, and the isolated block will drop to the ground. Basically I don’t want part of the scene to be floating.

Unfortunately the ‘ComponentEndOverlap’ node only checks if one of the connected objects is removed, rather than if all of them are. resulting in a spectacular domino effect if I remove one actor in game.

Does anyone know how i can do this?

Thanks

Bump

Can anyone help me with this?

Create an array to store your actors (block like components) and add them to it as they are created, OR you can get an array with “get all actors of class”. Then set this up:
OnComponentEndOverlap >>> “for each loop with break” (your array is the input) >>> “is overlapping actor” (the for each output : and the component that is checking) >>> a “branch” that checks the condition for whether or not it will enable physics (If overlapping actor then do not apply physics, and break from the loop. If not overlapping actor then apply physics. It will check through each one and if any are overlapping it will stop checking.

Hello @BallistikBiskit,

I think I may have some information for you to get going in the right direction. I would suggest looking into the “GetOverlappingComponents” node and checking whether or not it produces an empty array. I posted some example code below.

Code Explanation:
Essentially what the code above does is get the array of overlapping actors whenever an OnComponentEndOverlap event is thrown and checks whether that array is empty. If the array is empty(i.e. it is not overlapping with any other components) then it performs some action.

I hope this answer helps,

Farshooter

Much more elegant than what I came up with. :slight_smile:

Thank you both for your replies, I really really appreciate it!
Once again Farshooter you’ve saved the day! :wink:
I sort of had the general idea, but couldn’t figure out what to use to ‘check.’ now I know the ‘IsValid’ node fits well for operations like these. I threw in an ‘Event Begin Play’ node to check for any isolated parts to begin with too, and added a branch to check if the actor in question is overlapping the landscape, in which case physics are not enabled, and the piece stays ‘buried’ :slight_smile:

Thanks again guys, I really appreciate the help & explanations!