R6 Inverse Kinematics

Honestly, what I did was pretty hacky and I wouldn’t recommend it. BUT! I’m not one to dictate what you do.

First of all, I plant the feet if a torsoswing variable is bigger or smaller than 0 and it’s the sides turn.

local torsoSwing = 0
local side = false

-- You can do some wacky phase stuff to make this slower or faster with velocity.
torsoSwing = math.sin(tick())

if torsoSwing > 0 and side then
   side = not side
   -- Move your left foot here.
end

if torsoSwing < 0 and not side then
   side = not side
   -- Move your RIGHT* foot here.
end

Then, I lerp it. Pretty simple, but you may need to find a suitable amount to lerp the foot places by.

RlerpedFoot = RlerpedFoot:Lerp(rfplace, math.min(1/0.075*dt, 1))
LlerpedFoot = LlerpedFoot:Lerp(lfplace, math.min(1/0.075*dt, 1))

I then calculate a “raise” number, Pretty simple.

local raise = math.sin((RlerpedFoot - rfplace).magnitude/2)
local raise2 = math.sin((LlerpedFoot - lfplace).magnitude/2)

Then I move the legs with the IK module

ikFigure:LegIK("Right", RlerpedFoot + Vector3.new(0, (raise/2), 0))
ikFigure:LegIK("Left", LlerpedFoot + Vector3.new(0, (raise2/2), 0))

I’m not saying this is the best way to do this, it’s just the way I did it.

8 Likes