How do you make a part that has constant linear velocity (MAX force) turn?

Hi All,
I’m trying to figure out how linear velocity and related vector forces work, and I’m learning by making a blimp, but I’ve hit a roadblock: I’m unsure on how to make the blimp (part) turn while it has a constant linear velocity active on it. I can’t seem to find any dev forums or youtube videos talking about this topic (since most of them are within plane crazy)

I have somewhat got it to turn, but it’s extremely buggy and doesn’t turn in the correct direction 90% of the time, if at all.
https://gyazo.com/836e12f6c3f886fbf35d46ddfb56c5df

Here is the code I currently have for the blimp. If anyone has any suggestions / help to get it turning it would be much appreciated!

local model = script.Parent
local speed = model.Speed
local inc = model.I
local brake = model.B
local dec = model.D
local up = model.UP
local down = model.DOWN
local ui = model.UI.SurfaceGui.Frame
local speedUI = ui.Speed
local heightUI = ui.Height

local main = model.Main
local lv = main.LinearVelocity
lv.MaxForce = math.huge
local av = main.AngularVelocity
av.MaxTorque = math.huge
local vector = Vector3.new(0,0,0)

local heightSpeed = 1
local tweeningValues = false

local bodyGyro = Instance.new("BodyGyro")
bodyGyro.CFrame = main.CFrame
bodyGyro.MaxTorque = Vector3.new(400000, 400000, 400000)
bodyGyro.D = 1000
bodyGyro.Parent = main

local right = model.RIGHT
local left = model.LEFT
local rotation = 0

right.ClickDetector.MouseClick:Connect(function()
	rotation += 5
end)

left.ClickDetector.MouseClick:Connect(function()
	rotation -= 5
end)

game["Run Service"].Heartbeat:Connect(function()
	speedUI.Text = "Speed: "..speed.Value
	heightUI.Text = string.format("Height: %.2f",main.Position.Y)
	
	math.clamp(speed.Value,-20,20)
	lv.VectorVelocity = Vector3.new(main.CFrame.LookVector.X*speed.Value,heightSpeed,main.CFrame.LookVector.Z*speed.Value)
	
	if speed.Value > 0 then
		av.AngularVelocity = Vector3.new(0,(rotation)*0.2,0)
		--bodyGyro.MaxTorque = Vector3.new(0, 0, 0)
	else
		bodyGyro.MaxTorque = Vector3.new(400000, 400000, 400000) 
	end
	
	
	if rotation > 0.1 then
		rotation -= 0.1
	elseif rotation < -0.1 then
		rotation += 0.1
	else
		rotation = 0
	end
end)

inc.ClickDetector.MouseClick:Connect(function()
	speed.Value += 1
end)

dec.ClickDetector.MouseClick:Connect(function()
	speed.Value -= 1
end)

brake.ClickDetector.MouseClick:Connect(function()
	tweeningValues = true
	game.TweenService:Create(speed,TweenInfo.new(1),{Value=0}):Play()
	
	local currentHeightSpeedIncr = heightSpeed/10
	local index = 0
	repeat
		task.wait(currentHeightSpeedIncr/10)
		if heightSpeed < 0 then
			heightSpeed += currentHeightSpeedIncr
		elseif heightSpeed > 0 then
			heightSpeed -= currentHeightSpeedIncr
		end
		
		index += 1
	until index >= 10
	
	heightSpeed = 0
	tweeningValues = false
end)

up.ClickDetector.MouseClick:Connect(function()
	heightSpeed += 1
end)

down.ClickDetector.MouseClick:Connect(function()
	heightSpeed -= 1
end)

while task.wait(0.1) do
	
	if not tweeningValues then
		if heightSpeed < -0.1 then
			heightSpeed += 0.1
		elseif heightSpeed > 0.1 then
			heightSpeed -= 0.1
		else
			heightSpeed = 0
		end
	end
end

Perhaps set Massless to true on all parts that are spinning in the video? If you think you’ve tried everything, I’d suggest trying AlignOrientation (basically BodyGyro like you’ve already tried but relies on attachments like LinearVelocity) as it has variables like Responsiveness (a high value means minimal acceleration and deceleration).

Do you want it to be a precise turn, without any slip, or do you just want the end position to be exact?

Precise turning, sort of like simulated tweening but without using TweenService. I think in the code you can see the turn deceleration loop, where it slowly resets the turn radius to 0

game["Run Service"].Heartbeat:Connect(function()	
	if rotation > 0.1 then
		rotation -= 0.1
	elseif rotation < -0.1 then
		rotation += 0.1
	else
		rotation = 0
	end
end)

This ended up working, Thank you!
Applied the AlignOrientation to it so it modifies its CFrame to turn the blimp!
https://gyazo.com/86cb8bbc323af29a4910699ae7c19846

1 Like