• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Which child is the closest parent

Hi guys

Well, I have an instance "A" that looks at the nearest instance of a parent object "B". The parent object has three children "1", "2", "3". I need to have the instance "A" to be
able to deduct whether the parent object "B" is in the form of child "1", "2" or "3".

In my step event for instance "A" I have:

GML:
closest_enemy = instance_nearest(x, y, obj_B_parent);
...any advice on how to tell which child the nearest parent "B" is, is very welcome!

Thanks!
 
You could run a check on the object_index
Code:
switch (closest_enemy.object_index) {
   case 1: // Replace these numbers with the object names of the children
       
   break;
   case 2:
   
   break;
}
 
Top