It looks right in certain situations but that doesn’t affect how the angle limitations are determined, so once you get to higher limit angles that are either too short or too far then the calculations are reversed so the leg goes short when it should extend the furthest and the leg goes long when it should extend the least.
Hmm. I just edited some stuff in the IK module and now it works perfectly.
I just made a1 positive and subtracted 90 degrees from a2-a1, seems to be working fine.
This isn’t really what i want though, I was the leg to lift up all the way and kinda crouch instead of kneel, so the knee is up and isn’t into the ground
Well, this is the best result so far, thanks for helping though. I simply added a “base” value and did my calculations off of that angle, (math.pi/2) I also added 4 different positions, one being in between super close and perfect, so there weren’t that many artifacts.
This method of IK might not be ideal for what you’re trying to do. The method this thread depicts is pretty strict and what you want might be something more adaptive.
Adopting FABRIK style IK might be more what you’re looking for.
It’s because the solve isn’t accounting for the outward offset the C1 of the shoulder has. Technically it’s correct since the line from the shoulder C0 to the point is still in line.
You can correct this by offsetting the originCF by the shoulder C1 offset outward (c1.X) or by rotating the final planeCF to compensate for the offset (think of the offset + arm lengths as a right angle triangle: tan(l1+l2 / c1.X)). Rotating means you’ll also need to adjust for the loss in distance by pushing the planeCF forwards.
One case that needs to be adressed is when the axis is equal to Vector3.new()
A simple solution to this:
local axis = Vector3.new(0, 0, -1):Cross(localizedUnit)
local angle = math.acos(-localizedUnit.Z)
if axis == Vector3.new() then
axis = (angle == PI and Vector3.new(-1, 0, 0) or Vector3.new(0, 0, -1))
end
local planeCF = originCF * CFrame.fromAxisAngle(axis, angle)
This addresses two very specific cases where the math breaks Just wanted to add this on.
Has anyone applied this to the module? I can’t seem to figure out where/how to apply this, testing this on a 2.0 rig is accurate enough as it is but when I test this using the woman package the arms are way off target (potentially also due to the elbow offset?)
This looks useful, and I was actually looking for inverse kinematic tutorials. But I’m still unsure about how to use it for walking in where you put the script wise or if this is even for walking. This kinda went over my head so I can’t really figure out how to use it with walking.
I might just change names or something, i’m also not sure if this is only for animations instead of actual walking (For an fps game a couple friends and i are working on).
How do I use this for walking? (Or if its already for walking just tell me I don’t really know how this works)