Hello!
So currently, I’m designing a game that needs AI cars. Of course, at the moment, I have nodes mapped out on the streets (using sleitnick’s Node Map plugin), and I have a car chassis. I’ve been experimenting with the car to (attempt) to make it drive on its own, and it has been somewhat successful, but it pales in comparison to some of these other AI traffic systems. (The steering is terrible with tons of over-corrections/under-corrections, the actual node pathfinding that’s used to create set paths creates questionable routes, and it overall is just trash.)
So my question is how should I go about doing this. I have read all of the devforum posts about AI traffic systems and I’m still not quite sure. Should I not be using a car chassis, but instead, TweenService? I’ve tried using TweenService, but it has very odd outcomes, and often just ends up making the car float in the air.
Any help is appreciated
2 Likes
Still need help, any is appreciated!
1 Like
TweenService can be useful, but it is not suitable for simulating car physics.
Believing the information I just found on the internet, this may help you:
local function PIDController(Kp, Ki, Kd)
local integral = 0
local lastError = 0
return function(error, dt)
integral = integral + error * dt
local derivative = (error - lastError) / dt
lastError = error
return Kp * error + Ki * integral + Kd * derivative
end
end
Use an invisible part as a “guide”. This makes the pathfinding a whole lot simpler, because instead of moving a whole car and accounting for that, it just has to move one part. Once you’ve tweaked that to how you like it, you can use this part a root / base and have the rest of the car follow that part. For example, if you wanted the wheels to spin whenever the car is driving, check the root’s velocity and do with that what you will.
I’ll try this and I’ll let you know how it works!