• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! Click here to find out more!

GMS 2.3+ 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