Continuous Overlaping with multiple actors

I am looking for solution for continuous collision(overlaping) for multiple objects.
In my application i use many block which every have it’s own temperature, I mix them, put in one container etc and i want to transfer heat between them. Each block have collision sphere and when it overlap it start to transfer heat but i dont know how to handle overlaping with multiple blocks continously.

If it overlap with only block it is quite easy, i use OnComponentBeginOverlap and OnComponentEndOverlap i each i set value of bool isOverlaping variable. After that in Tick function i check: if(isOverlaping) {heat()};

But it not works for multiple objects, because some objects turn in variable true and another turn off…

The first thing you can try is instead of just using a boolean variable is to use an integer. In each begin overlap, add one to it and in each end overlap, subtract one. Then you can use the count to know how many other objects you’re overlapping at any given time.

If that doesn’t handle what you need, you could make an array of objects instead of the integer and add/remove from the array to give you a list of everyone you’re currently overlapping.

Either way you can also add some filtering if there’s only certain classes of objects you care about overlapping, just make sure if you make any checks like this in begin overlap, your end overlap uses identical logic or you’ll get out of sync.