But instead of using the chassis he made I used the one that Roblox made:
AI Script:
local Chassis = script.Parent
local Target = Chassis:WaitForChild("Target")
local Constraints = Chassis:WaitForChild("Constraints")
local Guide = Chassis:WaitForChild("Guide")
local RunService = game:GetService("RunService")
local Steer = 0
local Throttle = 0
RunService.Stepped:Connect(function()
local CF = Guide.CFrame
local Converted = CF:PointToObjectSpace(Target.Position)
for _, Constraint in next, Constraints:GetChildren() do
if Constraint:IsA("CylindricalConstraint") then
Constraint.AngularVelocity = Throttle
end
end
for _, Constraint in next, Constraints:GetChildren() do
if Constraint.Name == "SteeringPrismatic" then
Constraint.TargetPosition = math.clamp(Steer, -1, 1)
end
end
Steer = Converted.X
Throttle = Converted.Z
end)
The Problem is that it doesn’t Steer straight it just goes left and right while going to the target: robloxapp-20220902-1219175.wmv (3.7 MB)
Try using the car that the video is designed to see if it works. If it does, then you’ll need to change some code (or the car) to support the new car you have.
What I’m trying to say is check if this is either a scripting problem or a building problem. See if you can make a replica of that car in the video and test if it works. If it does, then it’s an issue with how the car is setup and you maybe could find better results in building support
Is the AI actual AI? If so, it will need to learn first. Like the 2nd post by @ChickHenEn said, you should try it with the provided chassis to test it first, to be sure you don’t waste your time and actually see how it works, and it will also help you understand how to make it work with the Roblox chassis.
for _, Constraint in next, Constraints:GetChildren() do
if Constraint.Name == "SteeringPrismatic" then
Constraint.TargetPosition = math.clamp(Steer, -1, 1)
end
end
You keep stating that the car you use isn’t doing the same thing as the car in the video. The script may work just fine, but not with the model YOU are using.
So how is the SteeringPrismatic different from the Roblox car compared to the one in the video.
The problem you are having is like saying ‘I tried to make bread using a recipe, but I changed one of the ingredients and it didn’t come out right’. You can’t blame the recipe if the ingredients are different.