Issue with inverse kinematics

Hello! I was working on a system that uses Inverse Kinematics to make the legs stand on the parts that they are colliding with, but when i crouch it breaks. How can i fix this?

With Inverse Kinematics:

Without Inverse Kinematics:

The way i made the crouch is by setting the HipHeight property of the Humanoid to -1.5, then play an animation that changes the positions of the legs.

This is how the crouching animation looks on the Animation Editor (Moon Animator)
image

The reason the crouching animation looks like this is because its priority is set to Core, because all the walking, idle and other animations also have their priorities set to Core. To make the legs look right, i have to keep the leg positions and rotations a little higher, to make them look correct.

This is a simple testing place for the system [R6 REQUIRED]:
IKTest.rbxl (60.2 KB)

1 Like

You should destroy the IK when starting to crouch.

So i added the function, that if an event is fired with value false it will destroy the IK, and if true, then creates it back.

The OnCharacterAdded function i had:

local function OnCharacterAdded(Character : Model)
	if table.find(CharacterTable, Character.Name) then return end

	CharacterTable[Character.Name] = {}
	task.spawn(function()
		CharacterTable[Character.Name].InverseKinematics = InverseKinematics.new(Character, {
			ikEnabled = true,
			ikExclude = {},
			maxIkVelocity = math.huge,
		})
	end)

	Character.Destroying:Connect(function()
		if CharacterTable[Character.Name].InverseKinematics then CharacterTable[Character.Name].InverseKinematics:Destroy() end
		CharacterTable[Character.Name] = nil
	end)
	
	ReplicatedStorage.IKToggle.Event:Connect(function(thing)
		if thing == false then
			if CharacterTable[Character.Name].InverseKinematics then CharacterTable[Character.Name].InverseKinematics:Destroy() end
			CharacterTable[Character.Name] = nil
		else
			CharacterTable[Character.Name] = {}
			CharacterTable[Character.Name].InverseKinematics = InverseKinematics.new(Character, {
				ikEnabled = true,
				ikExclude = {},
				maxIkVelocity = math.huge,
			})
		end
	end)
end
1 Like