Car DriveToPoint function

Hey there!
I would like to make a function for my code that does a similar thing to the walkToPoint function on a Humanoid but in a vehicle that runs off of the Steer and Throttle variables

I have looked and there is no prebuilt function for it. And the methods I have tried don’t work

I tried checking if a node was in range but it would slowly get itself off-course. I’ve looked for soloutions but the only thing I can find are Neural Networks but those only help with the learning and not the actual pathfinding to my knowledge

for i,v in pairs(nodes:GetChildren()) do

	local mag
	repeat
		mag = (seat.Position - v.Position).Magnitude
		seat.ThrottleFloat = 0.7
		--print(mag)
		if last then
			cf = CFrame.new(last.Position, v.Position)
			--print(cf)
			print(v.Attachment.WorldPosition.X)
			print(last.Attachment.WorldPosition.X)
			if v.Attachment.WorldPosition.X > last.Attachment.WorldPosition.X then
				seat.SteerFloat = math.abs(cf.Y)*-0.35
			else
				seat.SteerFloat = cf.Y*0.35
			end
		end
		
		wait()
	until mag > 2 and mag < 7 or mag > 23
	
	
	seat.Steer = 0	
	seat.Throttle = 0	
	--print(mag)

	last = v
end
1 Like