local beforeSubmerge = game.Workspace.Water.Position.Y + 1
local offset = 3
local count = 0
repeat wait() until game.Workspace.Part
game:GetService("RunService").Heartbeat:Connect(function()
if game.Workspace.Part.Position.Y < game.Workspace.Water.Position.Y then
local displasementMultiplier = math.clamp(-game.Workspace.Part.Position.Y / beforeSubmerge,0,1) * offset
print(displasementMultiplier)
if count % 10 then
game.Workspace.Part.Velocity = (Vector3.new(0,math.abs(-9.81) * displasementMultiplier,0) * (game.Workspace.Part.Mass*(game.Workspace.Part.Position - game.Workspace.Water.Position).magnitude/math.pow(0.5,2)))
end
count += 1
end
end)
Also, why are you using math.abs(-9.81)?
math.abs returns the + value for the calculation in the brackets following it, so basically you are saying 9.81.
Also Roblox gravity is 196.2 studs/second squared. Why are you using earth gravity of 9.81 meters/second squared?
i basically used unity’s gravity value cuz i literally retransformed it from c# to luau (the entire code was in c#) so i didnt know how it would react to this
gotcha, gonna try to use body position. i also tried to look for a solution on another post and they used water volume, depth, water resistance there etc. i may try to understand whats in it again