So i have this basic helicopter nearly 100% working. My only problem now is that it's not really moving forward where the helicopter is facing, it "kinda" works.
Basicly I can turn and go up and down but when I press forward it can only move forward in a 90 degree turn. Very weird. Here is a clip, please note I am always pressing forward https://i.gyazo.com/cad1fda5e18126f41742dea6c38ed15f.mp4
It is not moving forward when its like , I dont know, 45 degree turned, or 25 degree turned. Only when its 90 degree turned.
Any idea on how to solve this? I am using bodythrust
code
--Localscript
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 vel = plane.Main.BodyVelocity
local tru = plane.Main.BodyThrust
local ang = plane.Main.BodyAngularVelocity
local speed = 100
function MoveUp(action_name, action_state)
if action_state == Enum.UserInputState.Begin then
height = -5
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 = 5
end
if action_state == Enum.UserInputState.End then
height = 0
end
end
function MoveLeft(action_name, action_state)
if action_state == Enum.UserInputState.Begin then
turn = 1
end
if action_state == Enum.UserInputState.End then
turn = 0
end
end
function MoveRight(action_name, action_state)
if action_state == Enum.UserInputState.Begin then
turn = -1
end
if action_state == Enum.UserInputState.End then
turn = 0
end
end
function MoveForward(action_name, action_state)
if action_state == Enum.UserInputState.Begin then
moving = -50
end
if action_state == Enum.UserInputState.End then
moving = 0
end
end
function MoveBackwards(action_name, action_state)
if action_state == Enum.UserInputState.Begin then
moving = 50
end
if action_state == Enum.UserInputState.End then
moving = 0
end
end
RunService:BindToRenderStep("Update", Enum.RenderPriority.Input.Value, function()
local velocity = Vector3.new(0, 0, moving) * speed
tru.Force = velocity
ang.AngularVelocity = Vector3.new(moving, turn, 0)
vel.Velocity = Vector3.new(0,height,0)
end)
ContextActionService:BindAction("Up", MoveUp, false, "q")
ContextActionService:BindAction("Down", MoveDown, 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")
