- Home /
Question by
MannyLectro · Mar 28, 2014 at 11:01 PM ·
variablecountoverlapsphere
Overlapsphere : Count objects based on variable ?
Hi guys !
So here's what I am trying to do. I have a cube having a certain amount of a resource (water for example). I want this cube to detect other cubes around it and check if they have a lower amount of water. If it is the case, I'd like my first cube to divide the amount of water it has in excess compared to the others and give some to every cube around.
Any idea on how to do this ?
Comment
Answer by MileSplit · Mar 28, 2014 at 11:14 PM
This sounds like a great place to use Physics.spherecast, heres a link to the docs\
I would use hitinfo to find the GameObject inside the sphere
Hope this helps!
Your answer
![](https://koobas.hobune.stream/wayback/20220613141433im_/https://answers.unity.com/themes/thub/images/avi.jpg)