How to make a boat move along the water

I want to create a boat that can move along terrain water but not onto land. I also would like to know how I would go about making it lean to the side when you turn. I haven’t scripted any vehicles in the past so every reply matters!

Reply if you have any ideas or solutions for this problem.

There are a few ways.
I have used 2 propellors at the back which move the boat fore and aft , one rotating CW and the other CCW with the prop blades tilted for the opposite rotation. When both spin CW then the reverse thrust from one rotates the boat.

I’ve also used a VectorForce in a different boat for for/aft. Use a Torque to rotate the boat.
leaning the boat can be done with applying a sideways Force if the VectorForce is applied low under the boat for a powerboat (It will also tilt the bow up when a forward Force is applied. Maybe put the VectorForce higher for a sailboat to push the bow a bit down when going forward.

1 Like

I misunderstood the question

How would I script this into a vehicle seat to move the boat around using WASD?

1 Like

LocalScripts and remoteevents. Then you can use body gyros or just AssemblyAngularVelocity to rotate the boat

You don’t need to have remote events, unless you are worried about people exploiting or cheating.
BodyGyros can be used, but a Torque will do the exact same thing.

@Tris_banana you can script it just like you’d do a VehicleSeat. You could use Instance.Changed to check for a Property change of the VehicleSeat like a Steer or Throttle input and change the Forces in the VectorForce or Torque.

Ah yes, network owner, I forgot about that. But then you would have issues with people exploiting and having full control over the boat which wouldn’t be a good idea.

I found a script from a free model, I made sure to check that it isn’t malicious. It worked on the boat in the free model but when I put the script into my boat that I made, it doesn’t even move.

Script:

local boat = script.Parent

local seat = boat.PrimaryPart

--See: https://www.roblox.com/library/265487607/Cutter

local function GetCenterOfMass(parts)

local TotalMass = 0

local SumOfMasses = Vector3.new(0, 0, 0)

for i = 1, #parts do

local part = parts[i]

TotalMass = TotalMass + part:GetMass()

SumOfMasses = SumOfMasses + part:GetMass() * part.Position

end

return SumOfMasses/TotalMass, TotalMass

end

local function GetBackVector(CFrameValue)

local _, _, _, _, _, r6, _, _, r9, _, _, r12 = CFrameValue:components()

return Vector3.new(r6,r9,r12)

end

local function GetCFrameFromTopBack(CFrameAt, Top, Back)

local Right = Top:Cross(Back)

return CFrame.new(CFrameAt.x, CFrameAt.y, CFrameAt.z, Right.x, Top.x, Back.x, Right.y, Top.y, Back.y,Right.z, Top.z, Back.z)

end

local function GetRotationInXZPlane(cframe)

local Back = GetBackVector(cframe)

return GetCFrameFromTopBack(cframe.p, Vector3.new(0, 1, 0), Vector3.new(Back.x, 0, Back.z).unit)

end

--lonely function

local function getParts(parent)

local parts = {}

local descendants = parent:GetDescendants()

for i = 1, #descendants do

local part = descendants[i]

if part:IsA("BasePart") then

parts[#parts + 1] = part

end

end

return parts

end

--Create attachments and contraints for function

local parts = getParts(boat)

local centerOfMass, totalMass = GetCenterOfMass(parts)

local center = Instance.new("Part")

center.Anchored = true

center.Name = "CenterPart"

center.CanCollide = false

center.Archivable = false

center.Size = Vector3.new()

center.Transparency = 1

center.CFrame = GetRotationInXZPlane(seat.CFrame - seat.CFrame.p) + centerOfMass

center.Parent = boat

local attachment = Instance.new("Attachment")

attachment.CFrame = center.CFrame

attachment.Position = Vector3.new()

attachment.Parent = center

local vectorForce = Instance.new("VectorForce")

vectorForce.ApplyAtCenterOfMass = true

vectorForce.Attachment0 = attachment

vectorForce.Force = Vector3.new()

vectorForce.RelativeTo = Enum.ActuatorRelativeTo.Attachment0

vectorForce.Parent = center

local torque = Instance.new("Torque")

torque.RelativeTo = Enum.ActuatorRelativeTo.Attachment0

torque.Attachment0 = attachment

torque.Torque = Vector3.new()

torque.Parent = center

totalMass = totalMass + center:GetMass()

--Listen for input

seat:GetPropertyChangedSignal("Throttle"):Connect(function()

vectorForce.Force = Vector3.new(seat.Throttle, 0, 0) * 100000

end)

seat:GetPropertyChangedSignal("Steer"):Connect(function()

torque.Torque = Vector3.new(0, -seat.Steer, 0) * 100000

end)

In the free model, it leans to the side when you turn and that’s what I really like about it and also the fact that it worked.

It doesn’t work in my boat model and there are no errors, it just doesn’t move.

Did you name the parts according to the script’s names?

I always thought “BasePart” is a type of part, as a normal part. I don’t have to name them all BasePart.

1 Like

Well just incase I suggest you check if any of the parts in the free model are called basepart

Is the Seat inside the Boat Model as the PrimaryPart? local seat = boat.PrimaryPart

Is the script inside the VehicleSeat? local seat = boat.PrimaryPart

BasePart shoudn’t be the issue as that is the class of the Part, not the name.

Also, It looks like this script may be set up for an Anchored boat that moves with CFrame, not with Physics. It may drive over land if that’s the case.

Also, like I stated before, if you put the Attachment with the VectorForce inside it you can script it to lean sideways.

1 Like