Currently, that’s how the ship works:
- BodyGyro: Turning the ship
- BodyPosition: Fixing the Y-Position of the ship on the ocean level
- BodyVelocity: Moving the ship
What I try to improve:
- The pivot point of the ship should be at the front, not at the middle. (like real ships do)
- The ship should tilt a bit to the side where it’s turning.
- The ship should tilt randomly like it would be acting to the waves (doesn’t have to be exact)
local Base = script.Parent
local VehicleSeat = Base.VehicleSeat
local BodyGyro = Base.BodyGyro
local BodyPosition = Base.BodyPosition
local BodyVelocity = Base.BodyVelocity
local speed = 0
local steeringSpeed = 0
local waterHeight = 3
local maxSpeed = 20
local acceleration = 40
local maxSteeringSpeed = 5
local steeringAcceleration = 5
BodyPosition.Position = Vector3.new(Base.Position.X,waterHeight,Base.Position.Z)
BodyGyro.CFrame = Base.CFrame
while true do
speed = math.clamp(speed + VehicleSeat.Throttle*wait()*acceleration,-maxSpeed,maxSpeed)
steeringSpeed = math.clamp(steeringSpeed - VehicleSeat.Steer*wait()*steeringAcceleration,-maxSteeringSpeed,maxSteeringSpeed)
BodyVelocity.Velocity = Base.CFrame.LookVector*speed
BodyGyro.CFrame = BodyGyro.CFrame * CFrame.fromEulerAnglesXYZ(0,math.rad(steeringSpeed),0)
wait()
end
I tried some things but didn’t get it working yet. I’d be happy about some approaches on how I could achieve it.
Thank you!