#Zeppelin movements.

1 messages · Page 1 of 1 (latest)

dusk urchin
#

Hey Guys I need Help for Scripting Zeppelin Movements. I envisioned it so that as soon as the player sits down in the zeppelin, they would control it. I imagined the controls so that W/S could increase or decrease forward speed (forward movement), A/D would turn left or right, and Q/E would control altitude. I'm new to coding and initially used AI, but the AI just couldn't do it right. And the Controls don’t Reacts in play test at all and still after 2 Hours following the instructions from Ai.

So if anyone can Help me though this would be great🙏🏻

dusk urchin
#

local seat = script.Parent
local zeppelin = seat:FindFirstAncestor("Zeppelin-1")
local body = zeppelin:FindFirstChild("BODEY_Ellipsoid-Model-Zepelin", true)

local linearVelocity = body:FindFirstChild("LinearVelocity")
local alignOrientation = body:FindFirstChild("AlignOrientation")
local vectorForce = body:FindFirstChild("VectorForce")

local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

vectorForce.Force = Vector3.new(0, body:GetMass() * workspace.Gravity, 0)
vectorForce.RelativeTo = Enum.ActuatorRelativeTo.World

local SPEED = 30
local TURN_SPEED = 60
local LIFT_SPEED = 15
local yaw = 0

alignOrientation.RigidityEnabled = false
alignOrientation.MaxTorque = 100000
alignOrientation.MaxAngularVelocity = math.huge
alignOrientation.Responsiveness = 25

linearVelocity.MaxForce = 100000
linearVelocity.RelativeTo = Enum.ActuatorRelativeTo.World
linearVelocity.VelocityConstraintMode = Enum.VelocityConstraintMode.Vector

RunService.Heartbeat:Connect(function(dt)
if not seat.Occupant then
linearVelocity.VectorVelocity = Vector3.zero
return
end

local moveDir = Vector3.zero
local verticalDir = 0

if UIS:IsKeyDown(Enum.KeyCode.W) then
    moveDir = moveDir + Vector3.new(math.sin(math.rad(yaw)), 0, math.cos(math.rad(yaw)))
end
if UIS:IsKeyDown(Enum.KeyCode.S) then
    moveDir = moveDir - Vector3.new(math.sin(math.rad(yaw)), 0, math.cos(math.rad(yaw)))
end
if UIS:IsKeyDown(Enum.KeyCode.A) then
    yaw = yaw - TURN_SPEED * dt
end
if UIS:IsKeyDown(Enum.KeyCode.D) then
    yaw = yaw + TURN_SPEED * dt
end
if UIS:IsKeyDown(Enum.KeyCode.Space) then
    verticalDir = 1
end
if UIS:IsKeyDown(Enum.KeyCode.LeftShift) then
    verticalDir = -1
end

local targetVelocity = (moveDir * SPEED) + Vector3.new(0, verticalDir * LIFT_SPEED, 0)
linearVelocity.VectorVelocity = linearVelocity.VectorVelocity:Lerp(targetVelocity, dt * 3)
#

alignOrientation.CFrame = CFrame.Angles(0, math.rad(yaw), 0)
end)

outer drift
#

Well I wouldn't use keys because how would you add phone support then