Best way to check if NPC can use :MoveTo?

Hello, I’m trying to find the most efficient method to check if an NPC doesn’t have a need for PathfindingService to reach the target so it can just use :MoveTo as to reach the target directly.

Initially I used a single raycast from the NPC to the target to check for obstructions, then use :MoveTo if there were none. Then, I tried multiple raycasts straight down along the length of the initial raycast, checking for significant changes in elevation. This solved the problem with holes between the NPC and target, but was inefficient and definitely not the best way to go about this.

This brings me to the question, what’s the best way to check if an NPC can use :MoveTo? Do note in my case both the NPC and the Target are highly dynamic, meaning this would be checked quite a bit. Is there a good way to do this? Is it even worth it?

1 Like

Honestly it would probably be less expensive for you to just compute a path via PathfindingService instead of trying to determine if PathfindingService is needed because you would need to do some extensive queries to make that determination.