Question by
hakanerunsal · Nov 15, 2016 at 10:32 AM ·
c#colliders
Scan the child colliders?
Hi. I am working on a game, I have a character which has a lot of animations. I have 5 child collider on character at each side. And each collider has its own pick up animation. http://prntscr.com/d7hybf
Ball spawns at the edge and rolls down. The problem is, I cannot figure out how can I detect the closest ball and play the animation for it. I need something like this;
for (int i=1; i<6 ; i++)
{
if (check if the closest collider to character has a ball in it)
{
// if not, dont do anything
}
if (check if the second closest collider to character has a ball in it)
{
// lets say yes, play the pickup animation depending on colliders index
// start over from the closest collider
}
}
I dont know much about class communication so I dont wanna go for script for every child and send back the index if its collided. Gets so complicated to sort it out. Can anyone help me out?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612100721im_/https://answers.unity.com/themes/thub/images/avi.jpg)