Query: detecting characters not moving in a part

I already know about Touched and TouchEnded events. I also have used spacial queries :GetPartsInPart and :GetPartsInBoundingBox etc and they all work great. My query is how to detect immobile characters inside many parts within the game at the same time (like a button game with hitboxes) or something where there would be upwards of 500 hitboxes. This seems like it would be a huge cost in processing power.

On the other side if you’re completely immobile on a touch part it doesn’t trigger the event. What exactly do other developers use in such situations?

Use the least costly method. GetPartsInBoundingBox if you can.
If the parts are small and fairly symmetrical cubes use GetPartBoundsInRadius for maximum efficiency.

BUT, it’s best instead to run GetPartsInPart on the character part. Then fire the touched event for each block it touched. But this is abit messy to code, but it would be much more efficient than anything else.

could you use :GetPartsInPart / :GetPartsInBoundingBox but check the characters AssemblyVelocity? I don’t think there’s anyway to get around the O(n) but you could use whitelists to negate unneeded objects where possible

So perhaps just check for any HumanoidRootPart’s as OverlapParams.

A way to detect if a player is moving is using the Humanoid.MoveDirection.Magnitude and checking if it is greater than 0.

I also agree with this. This will limit the number of parts needed to be searched, greatly lowering your 500 hitbox count to whatever your player count is.

@Workindad01