What am I doing?
Hello guys! I want to make a boat on Roblox with my own buoyancy system with my own water.
What is the issue?
When I’m on the floaty thingy, it jitters and slowly pushes me off into a different direction.
Describing the system here:
The platform has 4 floaty points, and it experiences drag and angular drag at the center.
The one script in it:
local obj = script.Parent
local lineardrag = 7
local rotationaldrag = .1
local floatypoints = {script.Parent.F1,script.Parent.F2,script.Parent.F3,script.Parent.F4}
game["Run Service"].Heartbeat:Connect(function()
if script.Parent.AssemblyMass > 10000 then return end--Is Anchored?
script.Parent:SetNetworkOwner(nil)
for i,v in pairs(floatypoints) do--buoyancy calculations
v.Buoyancy.Force =
Vector3.new(0,
1*workspace.Gravity*(script.Parent.Size.X*script.Parent.Size.Z)/4*script.Parent.Size.Y*
math.clamp((workspace.Water.Water.Position.Y-(v.WorldPosition.Y
-script.Parent.Size.Y/2))/script.Parent.Size.Y,0,1),0)
end
if workspace.Water.Water.Position.Y < script.Parent.Position.Y - script.Parent.Size.Y/2 then return end
script.Parent.Center.Drag.Force = -script.Parent.AssemblyLinearVelocity * script.Parent.AssemblyMass * lineardrag--linear drag
script.Parent.AssemblyAngularVelocity *= math.exp(-rotationaldrag)--angular drag
end)
What solutions have I tried so far?
-I’ve tried changing the network ownership to the server
-I’ve tried setting the velocity to 0 if the boat or player’s assembly velocity was too small
-I have considered using align orientation, linear velocity, and align position instead, but then the boat would be too stiff (I want it to be able to be pushed around and stuff by say a bigger boat or something, if there is a way the boat can still be push able with these and fix my problem, please let me know)
Could you big brains out there help me out with stabilizing the boat, or finding more things to improve upon the script please?
I need help fast, or else floppa might drown from my lousy coding!