How do you prevent Humanoid flinging?

I am currently trying to spawn a wave of humanoid controlled NPCs. They are spawned above ground, have Ragdoll and FallingDown set to false, and they do not collide with each other. However they are still unsteady and unpredictable. Does anyone have any solutions to prevent humanoid controlled NPCs from flinging off the map? I would greatly appreciate it!

Thanks,
Anne

Side note:
I only recently set Ragdoll and FallingDown to false based on another forum post I had read: Best way of preventing humanoid tripping? However, this did not help :sweat_smile:

7 Likes

Make sure HipHeight is accurate. That solved a lot of my problems, especially with rigs that were not based on default characters.

10 Likes

In my games 99% of flings are ridiculously powerful, but they also happen relatively rarely.

In cases where characters are flinged extremely hard you could:
A) Reset their character
B) Try to set velocity and rotvelocity to 0

I personally do fling detection on every RenderStepped tick like this:

local function FlingPreventionUpdate()
if CurrentHum ~= nil and CurrentRoot ~= nil and Force ~= nil then
if CurrentRoot:IsDescendantOf(Workspace) then
if CurrentRoot.RotVelocity.magnitude >= 50 or CurrentRoot.Velocity.magnitude >= 50 then
CurrentRoot.RotVelocity = Vector3.new()
CurrentRoot.Velocity = Vector3.new()
print("Fling prevented")
end
end
end
end

My game doesn’t have high places so players would not reach high velocities while falling down. In games where people could fall down tall places, you can just exclude the Y velocity and check (velocity - Vector3.new(0, velocity.y,0)).magnitude

Though this is for client humanoids XD…

If flings are too often, then there might be tons of reasons why it’s happening. My guess is that collidable character limbs might be forced into map parts by animations.

45 Likes

Both replies helped to solve the issue to be honest. But for more intense cases the fling detection is useful.

5 Likes

Where do I put this script again?

LocalScript inside StarterCharacterScripts

what does the force represent? I’m just a bit confused.

2 Likes