I was trying to make a spaceship using BodyMovers. It is able to move like a regular vehicle, but I was having trouble making it able to tilt towards the player's camera, without which it can't fly. Below is the drive script so far anyways.
--Main Script for the spaceship
--By Ultimate_Miner64
script.Parent.MaxSpeed = script.Parent.Settings.MaxSpeed.Value
maxspeed = script.Parent.MaxSpeed
script.Parent.BodyPosition.Position = script.Parent.Position
script.Parent.BodyGyro.cframe = script.Parent.CFrame
value1 = 0
while true do
wait()
if script.Parent.Throttle == 1 then
script.Parent.BodyPosition.Position = script.Parent.Position
if value1 < maxspeed then value1 = value1 + script.Parent.Settings.Acceleration.Value end
script.Parent.Driving.Value = true
script.Parent.BodyVelocity.velocity = script.Parent.CFrame.lookVector*value1
script.Parent.Left.Value = false
script.Parent.Right.Value = false
end
if script.Parent.Throttle == 0 then
local VelocityX = script.Parent.BodyVelocity.velocity.X
local VelocityY = script.Parent.BodyVelocity.velocity.Y
local VelocityZ = script.Parent.BodyVelocity.velocity.Z
script.Parent.Driving.Value = false
script.Parent.BodyVelocity.velocity = Vector3.new(VelocityX / 1.01, VelocityY, VelocityZ / 1.01)
script.Parent.Left.Value = false
script.Parent.Right.Value = false
end
if script.Parent.Throttle == -1 then
if value1 > - maxspeed then value1 = value1 -script.Parent.Settings.Acceleration.Value end
script.Parent.Driving.Value = true
script.Parent.BodyVelocity.velocity = script.Parent.CFrame.lookVector*value1
script.Parent.Left.Value = false
script.Parent.Right.Value = false
end
if script.Parent.Steer == 1 then
script.Parent.BodyGyro.cframe = script.Parent.BodyGyro.cframe * CFrame.fromEulerAnglesXYZ(0,- script.Parent.Settings.TurnSpeed.Value,0)
script.Parent.Driving.Value = true
script.Parent.Right.Value = true
script.Parent.Left.Value = false
end
if script.Parent.Steer == -1 then
script.Parent.BodyGyro.cframe = script.Parent.BodyGyro.cframe * CFrame.fromEulerAnglesXYZ(0,script.Parent.Settings.TurnSpeed.Value,0)
script.Parent.Driving.Value = true
script.Parent.Left.Value = true
script.Parent.Right.Value = false
end
end
Help would be appreciated.
