Which is the best way to filter nearby parts?

A few days ago I was trying to make a filtering for nearby Tween animations, which excludes some unnecessary and out-of-range animations to play. However, while I was looking for functions to calcule the player distance, I don’t know which of those are the best way to do that.

  1. Filter based on Part’s bouding box;
  2. Filter based on Square’s radius;
  3. Filter based on Character’s distance.

Also, I’ll include a filtering to allocate who needs to play the animation, so it means I’m going to use these functions in NECESSARY calculations.

I think distance might be the best way, but I’m not sure

1 Like

Hi, before I write a code example, I want to make sure that I understand what you want to accomplish. You basically want to check if the player is in a specific area or at a specific distance before playing or stopping an animation, yes?

1 Like

Yes! That’s the point which I’m trying to get the best way :confused:

You’ll likely want to just check the distance from the character. The others are likely too much for what you need.

Unless you have a giant animation (lets say bigger than 100x100 studs) then you should be fine using the .Position property to filter based on the character distance. The reason is that you might have something too big (Like a space canon let’s say) where the primary part of the model is too far away from the actual canon. Since this space canon is big then the player might be right in between the cannon showing and the primary part not being close.

1 Like

I agree, seems like the distance is good for what I want.