So I’ve been wanting to make a pathfinding car, but I just don’t know how to do it. Theres little people who’ve done this recently, the only resources that I can find date back to years ago.
So my problem is that when I use carprimary:MoveTo(waypoint.Position), the car just teleports to the waypoints:
So the logical thing to do here is use a Humanoid right? Tried it. Failed. Car didn’t move, at all. So scrap the humanoid car idea, onto Tween.
So funny thing, when I try to tween the car, the body literally gets grabbed by some invisible god. It looks funny but isn’t what I’m trying to achieve.
The Tween basically does the same thing as the Humanoid, except that it literally yoinks the base of the car instead of just not doing anything to the car.
So all of my methods at making the car simulate a real player driving it, has failed. My main goal here is to make the car pathfind to a goalblock, but look like its actually driving.
Heres my script (has both tweenservice and moveto in there but one of them is commented out):
wait(5)
local PathfindingService = game:GetService("PathfindingService")
local TweenService = game:GetService("TweenService")
-- Variables for the car and destination, etc.
local car = script.Parent.VehicleSeat
local carprimary = script.Parent
local destination = game.Workspace.pathfindgoal
local path = PathfindingService:CreatePath()
path:ComputeAsync(carprimary.PrimaryPart.Position, destination.Position)
local waypoints = path:GetWaypoints()
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
--carprimary:MoveTo(waypoint.Position)
local tween = TweenService:Create(carprimary.PrimaryPart, TweenInfo.new(1), {Position = Vector3.new(waypoint.Position)})
tween:Play()
wait(1)
end
No problem! I recommend using [Moon Animator]( Moon Animator - Roblox) to weld your parts.
To make welds click the wrench icon when you have installed Moon Animator. Or you could weld all the parts your self which is very time confusing in my opinion.
i’ve tried out the plugin but the wheels and vehicleseat continue to stay in place. dont know why that is. should i have the base part anchored or unanchored?
No problem! I’m glad to help. For your issue, you could try lowering the destination and the model to the same Y position. That might make it look better.
If the rotation is weird then I probably messed up the rotation. I have multiple of methods of achieving the rotation. If that script doesn’t work, I’ll list all of the methods I am currently thinking of.