So I have 2 parents, right. 1 for melee combat enemy, and one for sword fighting enemy. Lets name them parent_melee and parent_sword. Now I want to cast a spell on one of the objects which have one of those parents. Like lets say I have an enemy bandit_lv1 and an enemy zombie_lv1. Different parents, different positions, different ID's. The targeting system works between different parents, like follows:
enemy1=instance_nearest(bandit_lv1)
enemy2=instance_nearest(zombie_lv1)
if(distance_to_object(enemy1.x,enemy1.y)<distance_to_object(enemy2.x,enemy2.y){
target=enemy1
}
else target=enemy2Where the executor of the code is the bandit. If there are 2 bandits on the field, it doesn't register that the second one is closer, it just goes to the zombie, and vice verse. How do I find the closest parent to the one selected? When I got all the variables drawn, the distance to the nearest instance with the same parent is a constant - 100000. Which means it doesn't calculate distance between same parents. When I tried point_distance it returns 0. How do I measure distance between 2 instances with same parents? I do not want to code in the instances, I want it to be parent sided. So how to calculate distance between 2 same parents?



Find content
Male
