Making Smart wandering npcs

Npcs can look pretty dumb at times, especially when they kiss the wall. That’s what I wanted to fix, and that’s also where the Pathfinding service came in. However, I realized using this service wouldn’t be efficient due to the number of parts it creates. Since I am having many npcs wander, this would cause another chunk of lag in the game. So, I decided to use raycasting, and shoot a ray about 5-10 studs away from the NPC. If the ray detects a wall, the NPC goes to a new point 90 degrees away. Does anyone have any other ideas of accomplishing the same thing?

1 Like

How so does the Pathfinding Service create parts? Most people make parts to visualize the waypoints so they can easily see them.

I guess that’s true but I have heard of people saying it does cause lag, correct me if I’m wrong

1 Like

Pathfinding itself I don’t belive causes lag. Most of the time it is how your code checks that the NPC has gotten to the position of the waypoint. Since certain methods tend to not be as responsive.

4 Likes