Self Driving Question

I want to know if it’s possible to make a Tesla like self-driving system when the player is in the drive seat and using A-Chassis when a player clicks a certain key it activates the self driving.

2 Likes

so like ai?? just taking it to a path? im not sure what you mean. you could just make it path-find to a location you select.

Even though I’m not good at scripting, you could assign positions to certain positions on the map and add a pathfind for each one like

Position1 = (position xyz here)

If u click a funny button

car go pathfind to position1

No, it’s like cruise control really, but it stays on the road and you don’t have to control the car.

You can just snap it to the direction its driving in i guess i still don’t understand.

Maybe raycast from both sides of the car and detect if it’s hitting the road lines? Change steering based off that.

Alright, I’ll try that but also

aiSensor.Touched:Connect(function(hitPart)
	local hitPosition = hitPart.Position
	local detectorPosition = aiSensor.Position
	local detectorRight = aiSensor.CFrame.RightVector
	
	local toObstacle = (hitPosition - detectorPosition).unit

	local angle = math.acos(detectorRight:Dot(toObstacle))
	
	local leftRay = Ray.new(detectorPosition, detectorRight * -10)
	local rightRay = Ray.new(detectorPosition, detectorRight * 10)

	local leftHit = workspace:FindPartOnRay(leftRay, car)
	local rightHit = workspace:FindPartOnRay(rightRay, car)

	if not leftHit and not rightHit then
		ACCOriginalSpeed = ACCOriginalSpeed * 0.5
	elseif not leftHit then
		print("Steer Left")
		car.DriveSeat.Steer = 1
	elseif not rightHit then
		print("Steer right")
		car.DriveSeat.Steer = -1
	else
		ACCOriginalSpeed = ACCOriginalSpeed * 0.5
	end

end)

image

Prints fine but it wont steer.

Setup pathpoints on the road, or make road pieces themselves be pathpoints, and then do your own pathfinding through that. You could also use the Roblox one and just use cost modifiers to make the pathfinding prioritize roads.

Yeah but is it possible for a script to change the steer while the humanoid is in the driver seat?

Definitely, you don’t have to make it fully reliant on player seat input. You can switch to a more controlled version when on autopilot, ignoring driverseat.steer

Thanks, but the only method I know is DriveSeat.Steer = -1 or DriveSeat.Throttle = 1

Alright, so I got the throttle and some other stuff down the steering is the issue.

    if isActivated then
        print("Steer:", steer)
        if steer < 0 then
            Chassis.UpdateSteering(math.abs(steer), -20)
            print("Steering Left")
        elseif steer > 0 then
            Chassis.UpdateSteering(steer, -20)
            print("Steering Right")
        else
            Chassis.UpdateSteering(0, 20)
            print("No steer detected, straightening")
        end
    end

Basically, it keeps steering in one direction (both calculated raycast directions are negative)

Hey there, yeah It’s totally possible tons of free scripts do have the cruise control, you can add some Invisible parts and If the car touches It to center It again, It’s not very hard to make. I have seen that somewhere but I do not remember where

Is it possible to weld to the roblox experiment car without it adding weight?

Change the property Massless to true
image