Limiting movement of AI bots

Hi,

IDEA :sweat_smile:

Let’s say that you want bots in your Roblox game to move around like the ones in GTA series, around the city, crossing roads etc.They are limited to sidewalks, zebra crossings and some other similar places, meaning that they won’t come onto the roads unless forced to.

What would be the best approach for this type of thing in Roblox, scripting wise? I have a couple of ideas:

  • Define custom routes - Kind of hectic work to define custom routes around the city for
    multiple bots

  • Automate all bots - This would probably be the best approach, at least that’s what I think.
    But to automate all Bots, I don’t know how to limit their movement, I could create random MoveTo points within the sidewalks but that wouldn’t look realistic. I want them to be as realistic as possible.

So, if you guys can help me out on this, I would really appreciate it. I don’t script that much but I do know some basic things.

Thanks,
toocrusty

I would suggest that you create nodes which act as points within a network of nodes, in which the NPCs will traverse across different vectors which connect these two nodes utilising path finding algorithms such as A*.

Essentially what you will have is that an NPC will want to travel from node A to node B, and your path finding algorithm will find out the route it will travel across other nodes in order to reach node B.

Edit: You could also look into roblox’s built in path finding functions.

6 Likes

you can replicate the side walks under the map and then do all the calculations down there and move the humanoid above the map

1 Like

I have thought about that too, but I was thinking you know without the need of nodes maybe?

1 Like

you can just use a part and make a path with a* and then use humanoid move to to each node of the path

1 Like

you can also have all shops and places a point to start and end the ai bot and randomly pick a start point and end point

1 Like

I’m not sure if this will work but I think it does.

First you will need to add a collision group to all the roads in the map. Then also add a (different from the road) collision group to each of the bots. Now you can use the PhysicsService to make those 2 collision group non collidable. So now when an AI walks on the road they just fall.
Here comes the part I’m not quite sure works but I think it does:
Once all of that is done you can use robloxes default pathfinding to calculate that algorithm for you. Make the AI follow that path and now they should only walk on the sidewalk.

This might be wrong robloxes pathfinding might ignore collision groups. If they don’t this might be the way to go.

2 Likes

I’m totally new to scripting but I will try this method. Thanks for sharing your thoughts.

1 Like