I am creating an infection simulator for my CS Class and need help on getting the distance of a clone. What I am currently doing is checking if the distance to my other clones is less than a certain value. the problem here is if every clone is in the radius it activates the script that runs when the clone is close. I am storing the clones in a list for easy changes of the clone. I am looking for a way to check for the closest clone without checking all clones in the radius. Also I need a way to access the object of the clone for the list.
Edit: Another thing Im looking for is an easy index reporter
I'm pretty sure that in order to find the closest clone you have to know how far away they are!
You don't have to keep your own list of clones because you can use the MY block in Sensing; one of the choices is MY (CLONES).
The only other suggestion I have is to look at MY (NEIGHBORS) which lists the sprites (including clones) near you.
you can do something like this
I tested ti out and it works, though you need to know the item number of a clone in the my [clones v] block. Here's a project showcaseing this I also included an item # of block in the project.
Brian's answer is the easiest way to escape from checking all your clones: use "my neighbors".
Then, depending the total number of clones and the number of neighbors (you will have there all their near sprites, including their own clones) you can reduce your list using:
To pick your closest clone, multiple options... you can use the "sort" block (from the list utilities library). Then, closest clone is: