Script Troubleshooting

Hey I’m trying to create a game involving Gerstner waves and I have the wave physics down, but I’m having trouble implementing boats that would be able to go up and down these waves, I’m sure it’s an easy fix but I’m not a scripter, can someone help me?

I can provide the scripts for anyone to look at.

The shape of gerstner waves is really complex so you should simplify the physics of your boat to be several small chunks of buoyancy. Then you can approximate the actual buoyancy of the whole boat with several of these. The more you use, the more assumptions you can make about how they interact with the shape of the wave. That is, if you have a bunch of small ones you can check their depth at a single point, making the assumption that the whole shape is submerged about the same depth in the water.

1 Like

Here’s the code for the ships if it helps:
while not _G.WavesLoaded do
wait()
end
wait(3)

local Ship = script:WaitForChild(“Ship”):Clone()
Ship.Parent = game.Workspace

local Main = Ship.Main

Main:SetNetworkOwner(nil)
while true do
local FrontY = _G.GetHeight((Main.CFrameCFrame.new(0,0,-40)).Position)
local BackY = _G.GetHeight((Main.CFrame
CFrame.new(0,0,50)).Position)

local FrontP = Vector3.new(Ship.Front.Position.X,FrontY,Ship.Front.Position.Z)
local BackP = Vector3.new(Ship.Back.Position.X,BackY,Ship.Back.Position.Z)

local RightY = _G.GetHeight((Main.CFrame*CFrame.new(10,0,0)).Position)
local LeftY = _G.GetHeight((Main.CFrame*CFrame.new(-10,0,0)).Position)

local Dif = FrontP-BackP
local Mid = BackP+Dif/2

local ShipHeight = _G.GetHeight(Main.Position)

local x,y,z = Main.CFrame:ToOrientation()

Main.BodyPosition.Position = Vector3.new(0,ShipHeight-3,0)


local AngX = math.atan2((FrontY-BackY), 90)
local AngZ = math.atan2((RightY-LeftY), 20)
Main.BodyGyro.CFrame = CFrame.Angles(0,y,0) * CFrame.Angles(AngX,0,AngZ)

Main.Steer.AngularVelocity = Vector3.new(0,-Ship.VehicleSeat.Steer*1,0)
Main.Engine.Velocity = Main.CFrame.LookVector*25*Ship.VehicleSeat.Throttle

Ship.VehicleSeat:SetNetworkOwner(nil)

--game.Workspace.TestPart.Position = Vector3.new(game.Workspace.TestPart.Position.X,_G.GetHeight(game.Workspace.TestPart.Position),game.Workspace.TestPart.Position.Z)

game:GetService("RunService").Stepped:Wait()

end