I don't know what Engine/Framework you're using, but normally you should get the X and Y position of the cursor whenever a click event is fired, and check if that overlaps with the current position of the robot's bodypart to execute the change of state