Helicopter physics not working properly

Hey,

I am trying to make a helicopter but when I try steer it to for example the left it continues straight until it finally goes in the direction it’s pointing. I know it has something to do with that it needs to slow down the force going forward and the force going to the Left.

These are the body movers im using: Body Gyro, Body Force, BodyVelocity.

What I am worried about is Body force as that is the one making the helicopter able to fly in the direction it needs too.

Local Script that handles every body mover and movement:

local ContextActionService = game:GetService("ContextActionService")

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local plane = script.Obj.Value

local RunService = game:GetService("RunService")
local height = 0
local turn = 0
local moving = 0
local Tilt = 0


local MoveRightKeyDown = false
local MovetLeftKeyDown =false

local vel = plane.Main.BodyVelocity
local tru = plane.Main.BodyForce
local BodyGyro = plane.Main.BodyGyro

local speed = 20

function MoveUp(action_name, action_state)
	if action_state == Enum.UserInputState.Begin then
		height = 15
	end
	if action_state == Enum.UserInputState.End then
		height = 0
	end
end

function MoveDown(action_name, action_state)
	if action_state == Enum.UserInputState.Begin then
		height = -15
	end
	if action_state == Enum.UserInputState.End then
		height = 0
	end
end

function MoveLeft(action_name, action_state)
	MovetLeftKeyDown = false
	if action_state == Enum.UserInputState.Begin then
MovetLeftKeyDown = true
	while MovetLeftKeyDown do
		wait(0.1)
		turn = turn + 10
	end
	 elseif action_state == Enum.UserInputState.End then
      MovetLeftKeyDown = false
end

end



function MoveRight(action_name, action_state)
	MoveRightKeyDown = false
	if action_state == Enum.UserInputState.Begin then
MoveRightKeyDown = true
	while MoveRightKeyDown do
		wait(0.1)
		turn = turn - 10
end
	 elseif action_state == Enum.UserInputState.End then
      MoveRightKeyDown = false
end

end

function MoveForward(action_name, action_state)
	if action_state == Enum.UserInputState.Begin then
		moving = -20000
		 Tilt = -15
	end
	if action_state == Enum.UserInputState.End then
		moving = 0
		Tilt = 0
	end
end

function MoveBackwards(action_name, action_state)
	if action_state == Enum.UserInputState.Begin then
		moving = 20000
		 Tilt = 15
	end
	if action_state == Enum.UserInputState.End then
		moving = 0
		Tilt = 0
	end
end



RunService:BindToRenderStep("Update", Enum.RenderPriority.Input.Value, function()
	
	BodyGyro.CFrame = CFrame.Angles(0, math.rad(turn), 0) * CFrame.Angles(math.rad(Tilt), 0, 0)
	if plane.DriverSeat.Velocity.magnitude >= 150 then
		tru.Force = Vector3.new(0,0,0)
	else
		
		tru.Force = plane.Main.CFrame.LookVector * (-moving * 2 )
	end
	print(plane.DriverSeat.Velocity.magnitude)
	vel.Velocity = Vector3.new(0,height,0)
	
end)

script.Obj.Changed:Connect(function()
	ContextActionService:UnbindAction("Down")
	ContextActionService:UnbindAction("Up")
	ContextActionService:UnbindAction("Left")
	ContextActionService:UnbindAction("Right")
	ContextActionService:UnbindAction("Forward")
	ContextActionService:UnbindAction("Backwards")
end)

ContextActionService:BindAction("Down", MoveDown, false, "q")
ContextActionService:BindAction("Up", MoveUp, false, "e")
ContextActionService:BindAction("Left", MoveLeft, false, "a")
ContextActionService:BindAction("Right", MoveRight, false, "d")
ContextActionService:BindAction("Forward", MoveForward, false, "w")
ContextActionService:BindAction("Backwards", MoveBackwards, false, "s")
2 Likes

I noticed that you’re checking to see if the user is hold a key down. This can actually be handled by UserInputService:IsKeyDown(Enum.Keycode.KEYCODE). In fact, most of your code that uses user input should be using UserInputService.

As for movement, personally, I would’ve wrapped this into a RunService heartbeat.

Also, if you’re changing the properties of your plane / helicopter, why’re are you listening for change and unbinding your events?

1 Like

It is still not working. The helicopter is still slow to decrease the speed. It behaves like it’s sliding like a car with no traction but in the air.

Do you have a place file that you can upload where I could test this for myself? It’s hard to go off something that physically simulated via text.

Sure, here it is.Heli.rbxl (83.0 KB)