How to achieve Vehicle AI that utilizes a chassis and follows traffic laws?

Title is fairly self-explanatory, I want a vehicle AI system to be less stiff and act like a player would except they’re designated to a specific route and follow traffic laws.

I see so many of these traffic/vehicle AI videos or tutorials that don’t utilize any sort of chassis, the wheel’s just move, and they are stiff, don’t move like real wheels, and don’t act like a vehicle just a moving object bound to a path.

1 Like

For this you would need to learn how to code or hire someone to do it for you. Nobody is going to write a fully working professional vehicle system for you. If you have a specific question about constraints or design style maybe make your question less vague.

1 Like

I sorta worded my post a bit wrong, I wasn’t asking for someone to write me an entire vehicle AI system lol, but rather tell me where to start and an idea of how to achieve this since I’m a bit lost.

1 Like

I remember trying to do this a while ago, the way i planned on doing it is using the pathfinding service or waypoints or nodes i put myself and then have a script that makes the car drive to those nodes.

I found these two posts a while ago which helped me to learn how to steer a car into the waypoints

for a legacy car, i seen using :Dot() is the correct way to go to get the steering angle to drive your car to a point, while for a car made out of constraints which is usually most cars, you would use math.atan2 or math.deg to determine the steering angle to drive to a point.
Combining this with the pathfinding service, or nodes that you placed (or a* pathfinding), you can script a autonomous car system that follows traffic rules and drives correctly.

2 Likes

Roblox did an open sourced game that has vehicles and npcs that follow traffic laws and streets:
City People Cars - Roblox
It’s got a few bugs, but take a copy to see how they did it.

5 Likes

The best advice for this would be to separate different functionalities. Make a vehicle system with limited inputs first, such as turning, throttle, lights, etc. Also consider outputs like absolute world position, state, speed, etc.

Then once the car behaves as expected with manual inputs, create a completely separate AI system that takes control of each car in the game and is only given the inputs and outputs available from the car controller for each car. Make sure to only use inputs or outputs that a player would know, such as world position or what’s in front of the car.

1 Like

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