So I’m trying to make a car AI that moves on a track for me and my friend’s game. I’ve came across some info on it, with multiple methods. Specifically PathFinding, Neural Networks, and using scripts to change the VehicleSeat’s values. At the moment I’ve been testing PathFinding, and using it with a simple car.
The problem is, when it moves to the object, instead of slowly rolling there, it instantaneously teleports directly to it. I want it to roll over to there using PathFinding.
And an extra question incase anyone might now about it: Is there a way to make an AI car move through a track? My idea was to take the VehicleSeat values such as Throttle/Steer, and use PathFinding to allow it to utilize it in a script, making the car move through the track. Now it seems that this won’t work. Any ideas?
About the main issue, here’s a screenshot of my Explorer, as well as the script.
ScreenShot:
Script:
wait(5)
local PathfindingService = game:GetService("PathfindingService")
-- Variables for the car and destination, etc.
local car = script.Parent.MainCar.Part
local carprimary = script.Parent
local humanoid = script.Parent.Humanoid
local destination = game.Workspace.DestinationTest
local throttle = script.Parent.MainCar.Part.VehicleSeat.Throttle
-- Create the path object
local path = PathfindingService:CreatePath()
-- Compute the path
path:ComputeAsync(carprimary.PrimaryPart.Position, destination.PrimaryPart.Position)
-- Get the path waypoints
local waypoints = path:GetWaypoints()
-- Loop through waypoints
for _, waypoint in pairs(waypoints) do
local part = Instance.new("Part")
part.Shape = "Ball"
part.Material = "Neon"
part.Size = Vector3.new(0.6, 0.6, 0.6)
part.Position = waypoint.Position
part.Anchored = true
part.CanCollide = false
part.Parent = game.Workspace
-- Move car to the next waypoint
carprimary:MoveTo(waypoint.Position)
end
EDIT: Here’s A GIF as well
Thanks for any help.