NPC Cars in Roblox studio

Just wondering how would everyone go about a NPC Car with path finding in it?

I aim to make it path find to certain locations and follow the roads as much as possible. I was thinking about places 111 Parts at the points where roads change direction and then use a custom path finding system to set a route along those parts and then use a motor to accelerate the car forward while and it steers until the look vector is facing within a few degrees of the point, doing that repeatedly along the chosen route. Would that be a good solution? I also would like to know should i put the car on server side or client? Server would be laggy most likely and Client is open to manipulation.

Any help is much appreciated!
Thanks

6 Likes

You can use pathfindingservice (FindPathAsync), it takes in two vector3s (positions) which it then generates a path between, to be more advanced you could use createpath and give the car some constraints via costs making it stay in its own lane for example, final touches you could send out 4-5 raycasts at the front of the car to check if the car is going to hit anything and apply breaking (if your using a chassis) based on the proximity

5 Likes

A couple years ago Roblox made a demo place with cars and NPCs that followed traffic rules.
Instead of putting it under the Tutorials tab they put it under the Art tab…
You can get the .Rbxm file there to see how they made it work.

6 Likes

That sounds cool but this is more of a trail than a road, sorry for not specifying

Will try and modify this tonight :slight_smile:
Thanks

I’d never played it before, so I tried it last night. A lot of a Grand Theft Auto feel to it.
That being said it has a lot of vehicle glitches even though it was only updated a couple of months ago.
Vehicles seem to have only a waypoint at the next intersection so if they get off course they aim there, not to the lane they are supposed to be in. There’s one intersection at the edge where vehicles kept piling up. I spent waaay to much time putting 4 bullets into each of the vehicles so they would start smoking, then directed them to that intersection so they’d all get stuck there. I think I had about 8 of them stuck there before I quit!

Average Pile up maker:

They seem to have reached same idea as i have, though in my one it will not be lanes, instead it will be a trail of painted terrain. I will have a go at it tonight i think and see where it goes

1 Like

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