I made simple ragdoll script for knockback (tbh found example and changed it), but when dummy gets up he flings.
I’m good, but not that nice in scripting (this reason why i found example), i want to find easiest way to do it.
Or i don’t need to change script to fix this?
Also i really want you to explain how to do it, not just recommend me some things. I already said that i’m good, but not that nice. =(
local humanoid = script.Parent:WaitForChild("Humanoid")
humanoid.BreakJointsOnDeath = false
local sockets = {}
local joints = {}
local function ragdoll()
for i, socket in ipairs(sockets) do
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
end
for i, joint in ipairs(joints) do
joint.Enabled = false
end
humanoid.PlatformStand = true
wait(0.1)
script.Parent["Right Leg"].CanCollide = true
script.Parent["Left Leg"].CanCollide = true
script.Parent["Right Arm"].CanCollide = true
script.Parent["Left Arm"].CanCollide = true
script.Parent["Head"].CanCollide = true
end
local function unragdoll()
if humanoid.Health > 0 then
for i, socket in ipairs(sockets) do
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
end
for i, joint in ipairs(joints) do
joint.Enabled = true
end
humanoid.PlatformStand = false
wait(0.1)
script.Parent["Right Leg"].CanCollide = false
script.Parent["Left Leg"].CanCollide = false
script.Parent["Right Arm"].CanCollide = false
script.Parent["Left Arm"].CanCollide = false
script.Parent["Head"].CanCollide = false
end
end
script.Parent.Ragdoll.Event:Connect(function(duration)
task.spawn(function()
ragdoll()
end)
wait(duration)
task.spawn(function()
unragdoll()
end)
end)
humanoid.Died:Connect(function()
task.spawn(function()
ragdoll()
end)
end)
for index,joint in pairs(script.Parent:GetDescendants()) do
if joint:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local a1 = Instance.new("Attachment")
local a2 = Instance.new("Attachment")
a1.Parent = joint.Part0
a2.Parent = joint.Part1
socket.Parent = joint.Parent
socket.Attachment0 = a1
socket.Attachment1 = a2
a1.CFrame = joint.C0
a2.CFrame = joint.C1
socket.LimitsEnabled = false
socket.TwistLimitsEnabled = false
joint.Enabled = true
table.insert(sockets, socket)
table.insert(joints, joint)
end
end
I think the reason for flinging is that the HumanoidRootPart tries to quickly rotate such that its upvector would be vertical. This probably causes a high impulse to be applied to the HumanoidRootPart because of its high velocity contact with the ground.
What I did in the ragdoll system that I’m currently working on was making the HumanoidRootPart CanCollide false while the character is ragdolled and using an AlignPosition to move the RootRigAttachment of HumanoidRootPart to the position of the RootRigAttachment of LowerTorso and an AlignOrientation to keep the HumanoidRootPart upright. In addition to preventing ground collisions, this makes sure that the HumanoidRootPart doesn’t affect the physics of the ragdolled character as long as AlignPosition.ReactionForcesEnabled is false.
Well, the code you have already creates attachments. At the moment they are used for BallSocketConstraints. Just change the code such that if joint.Name == "RootJoint", the code creates an AlignPosition instead of a BallSocketConstraint (the RootJoint is between HumanoidRootPart and Torso).
I also used the AlignOrientation to rotate the HumanoidRootPart horizontally based on LowerTorso rotation so that the direction of the HumanoidRootPart’s look vector after getting up is based on the orientation the lowertorso has before getting up.
I found topic with the same problem (ofc i was finding for the same problem, but i didn’t find this topic before), and in the solution was code that makes humanoid root part can’t collide (like you said), massless and jump state falls, get up state false and ragdoll state true.
it will work? right?
Omg, that works!
Here is the topic where i found solution: Flinging problem with Ragdoll - #5 by FireyMcBlox
What i need to choose as a solution? You who said why it’s flings and change humanoid root part cancollide to false? Or my answer with link to the solved same situation?
Well, if the property changes and disabling those spesific humanoid states fixes the problem and using an alignposition and an alignorientation is unnecessary, then maybe mark your post as a solution.