Heya! So, I’ve been working on a water physics engine, I am now trying to make drag in the water to slow the player down when they aren’t holding down an input, I tried to make the drag force proportional to the player’s velocity using the drag formula. I have used the drag formula to calculate the drag that should be applied to the player., but trying to apply this force is the issue, as a vector3 is needed. Making this unit a vector3 causes the player to fling infinitely in the other direction.
Code:
swimTrigger.Event:Connect(function(inWater)
if inWater == true then
connection = RS.Heartbeat:Connect(function()
task.wait()
local hrpVel = hrp.AssemblyLinearVelocity
local dragForce = (.5*hrpVel.Magnitude^2*waterDragCoefficent*.5)
local appliedDrag = Instance.new("VectorForce")
appliedDrag.RelativeTo = Enum.ActuatorRelativeTo.World
appliedDrag.Force = --Missing applied force
appliedDrag.Name = ("DragForce")
appliedDrag.Attachment0 = hrp:FindFirstChildWhichIsA("Attachment")
appliedDrag.Parent = hrp
end)
elseif connection then connection:Disconnect() end
end)