the way control works, is it too quickly gains speed (not realistic for tank game), and stays like that till you drive off a hill and gain even more speed.
is there anyway to fix/optimize my code, to make it work the way how irl tank engines work, gaining speed slowly till defined max speed?
uis.InputBegan:Connect(function(input, processed)
if processed then return end
if not seat then return end
if not seat:IsA("VehicleSeat") then return end
if seat.Occupant ~= humanoid then return end
local attributes = vehicle:GetAttributes()
if input.KeyCode == Enum.KeyCode.W then
while uis:IsKeyDown(Enum.KeyCode.W) do
chassis:ApplyImpulse(chassis.CFrame.LookVector * -seat.Throttle * attributes.ForwardPower)
task.wait()
end
end
if input.KeyCode == Enum.KeyCode.S then
while uis:IsKeyDown(Enum.KeyCode.S) do
chassis:ApplyImpulse(chassis.CFrame.LookVector * seat.Throttle * -attributes.BackwardPower)
task.wait()
end
end
if input.KeyCode == Enum.KeyCode.D then
while uis:IsKeyDown(Enum.KeyCode.D) do
chassis:ApplyAngularImpulse(Vector3.new(0, -attributes.SteerPower * seat.Steer, 0))
task.wait()
end
end
if input.KeyCode == Enum.KeyCode.A then
while uis:IsKeyDown(Enum.KeyCode.A) do
chassis:ApplyAngularImpulse(Vector3.new(0, attributes.SteerPower * -seat.Steer, 0))
task.wait()
end
end
end)