Script Efficiency Problem (distance between objects, region3)

I am faced with a programming objective to which I am having trouble thinking of an efficient method to solve. I would appreciate any help/suggestions.

Problem: An object (let’s pretend it’s a vacuum) sucks in players when they get within a certain range of the vacuum. How do I calculate if the player is close enough to be sucked in?


  1. Use a continuous loop and a region3 surrounding the vacuum to check. (very resource intensive though…)
  2. Get a list of all the players and continuously check if the vector3 distance between each one and the vacuum is short enough (also requires checking for new players then)
  3. Create an invisible part around the vacuum and perform the suction onTouch (onTouch is unreliable though)

Thanks! :smiley:

I think this way is the easiest and best way to do this. Or maybe magnitude.