What is a good way for many NPCs to follow a player?

Hello! Recently, I have been building a game similar to the popular mobile game ‘crowd city’. The player has to gain as many NPCs as possible to follow them. Once they have a sizable amount of NPCs, they can command them to attack other players’ NPCs.

I have been struggling to find a good way to let NPCs follow a player. Many issues have arisen, due to there being a large number of NPCs.

I found a Youtube tutorial, I think it was this one that displayed a way for an NPC to follow a player. Unfortunately, this does not work well with many NPCs, and they collided with each other.

Removing collision solves this, though they then cluster together, which is undesirable.

Could anyone could suggest an effective way of allowing a large amount of NPCs to follow a player, whilst maintaining an organised formation and not causing much lag?

Note: I apologise if I haven’t given enough details, been vague or have not formatted this correctly, as this is my first time posting here. I am happy to attach more information if needed.

2 Likes

Would it be possible for you to set up a hitbox that bumps the NPCs away from each other. Or a collision group that lets them walk through each other?

1 Like

Creating hitboxes for the NPCs seems like a good solution, I will try that. Would putting them into a formation also work?

Like this:

(The green is the player, and the yellow are the NPCs. The formation would be different depending on the amount of NPCs. Instead of following the player directly, they would follow their allocated square)

That could work nicely! This reminds me of how simulator pets are placed, if you know what I mean!

I think I will use that solution. Thank you for your contribution!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.