Skip to content

Commit

Permalink
fix inverse kinematics target handler
Browse files Browse the repository at this point in the history
  • Loading branch information
katsumi143 committed Mar 2, 2024
1 parent cfd7522 commit b3027ee
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/client/characters.luau
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,26 @@ function module.create(player: Player, model: Model): types.Character?
}
character.kinematics[child.Name] = kinematic

local function handle_target(instance: Instance)
if instance:IsA("Attachment") then
local connection: RBXScriptConnection?
local function handle_target(instance: Instance?)
if instance and instance:IsA("Attachment") then
kinematic.control_target = instance
kinematic.control_target_identity = child:GetAttribute("offset")

if connection then
connection:Disconnect()
connection = nil
-- TODO: remove reference from connections table
end
end
end

local target = child.Target
if target then
handle_target(target)
else
table.insert(connections, child:GetPropertyChangedSignal("Target"):Once(handle_target))
connection = child:GetPropertyChangedSignal("Target"):Connect(handle_target)
table.insert(connections, connection :: RBXScriptConnection)
end
elseif child:IsA("Motor6D") and child.Name == "Root" then
character.waist_motor = child
Expand Down

0 comments on commit b3027ee

Please sign in to comment.