I have this function that checks the distance between 2 objects. When it’s found the closest one it shows a widget on top of the target. I can’t figure out how to turn the widget back off when a new closer target is found please help ):
Store a reference of the closest. Each time you run the function to check for closest you need to compare the stored closest against the new closest. If the same do nothing. If different, call an event to disable widget, then enable on new closest, update the stored closest reference.
1 Like