Skip to content

Commit

Permalink
First test to fix buildRagdoll
Browse files Browse the repository at this point in the history
  • Loading branch information
TrippTrapp84 committed Aug 30, 2023
1 parent 65ddca3 commit bbbe974
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/buildRagdoll/buildConstraints/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ for _, v in pairs(script:GetChildren()) do
constraints[v.Name] = v
end

function getConstraintTemplate(jointName)
local function getConstraintTemplate(jointName)
jointName = getLastWordFromPascaleCase(jointName)
return constraints[jointName] or constraints.Default
end

function createConstraint(jointData)
local function createConstraint(jointData)
local jointName = jointData.Joint.Name
local constraint = getConstraintTemplate(jointName):Clone()

Expand Down
35 changes: 20 additions & 15 deletions src/buildRagdoll/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,32 @@ local buildCollisionFilters = require(script:WaitForChild("buildCollisionFilters
...
}
--]]
function buildAttachmentMap(character)
local function buildAttachmentMap(character)
local attachmentMap = {}

-- NOTE: GetConnectedParts doesn't work until parts have been parented to Workspace, so
-- we can't use it (unless we want to have that silly restriction for creating ragdolls)
for _, part in pairs(character:GetChildren()) do
if part:IsA("BasePart") then
for _, attachment in pairs(part:GetChildren()) do
if attachment:IsA("Attachment") then
local jointName = attachment.Name:match("^(.+)RigAttachment$")
local joint = jointName and attachment.Parent:FindFirstChild(jointName) or nil
if not part:IsA("BasePart") then return end

if joint then
attachmentMap[attachment.Name] = {
Joint = joint,
Attachment0 = joint.Part0[attachment.Name];
Attachment1 = joint.Part1[attachment.Name];
}
end
end
end
for _, attachment in pairs(part:GetChildren()) do
if not attachment:IsA("Attachment") then return end

local jointName = attachment.Name:match("^(.+)RigAttachment$")
local joint = jointName and attachment.Parent:FindFirstChild(jointName) or nil

if not joint then return end

local Attachment0 = joint.Part0:FindFirstChild(attachment.Name);
local Attachment1 = joint.Part1:FindFirstChild(attachment.Name);

if not Attachment0 or not Attachment1 then return end

attachmentMap[attachment.Name] = {
Joint = joint,
Attachment0 = Attachment0;
Attachment1 = Attachment1;
}
end
end

Expand Down

0 comments on commit bbbe974

Please sign in to comment.