R6 IKPF (Inverse Kinematics Procedural Footplanting)

Open Source IKPF System For R6

Derived from @Scarious’s code, revamped by @iGottic for R15, remade again by @dthecoolest for R6.

Due to request from the original post for an R6 version and @PysephDEV from my CCDIKController module page lol.

Credits:

@iGottic - It’s uses the exact same system as the R15 IKPF with rotating the foot in a circle via CFrame maths.

@Scarious - The original Creator

me - CCDIK Module was used as the IK method showcasing the power of CCD Inverse kinematics to easily setup IK.

Showcase

Sound on for source engine grass footstep noise I got from the tool box:

Quack

Features

  • Procedural Foot planting (duh)

  • Customizable foot step noises + custom implementation possible (detect floor material via a signal connection)

  • Replication

  • And it’s for R6

Cons:

  • Not R15 compatible

  • Not animation compatible (Creates an custom invisible upper leg for the legs in order to get that smooth cartoony effect)

  • Not fully optimized as it’s always running

How do I get it?

It’s just a local script that you can drag and drop into StarterPlayerScripts

https://www.roblox.com/library/7503546100/R6ProceduralAnimations

Attribution and Credit

You are free to use this resource on any of your games with giving credit in the description. However, the script source must always contain the following information:

  • The original script creator (Scarious)
  • Credit to original changes (dthecoolest, iGottic)
  • A list of changes you or your organization made to the script

If the following conditions are not met, your edits to the script may not be distributed.
Otherwise, you’re in the clear!

79 Likes

Yooo seesh I have been looking for a resource like this for a long time

This is actually a very cool resource! thank you for making it available!

This is really good but they has to be a way to switch it off when jumping :cry:

1 Like

I am aware that this is open-source so I will attempt at fixing this myself however:

I am not too sure how this occurred but when I teleported the local character using math.huge, it generated thousands of errors. I do not know if this can affect other things.

workspace["1ceyberg"]:MoveTo(Vector3.new(0,math.huge,0))

Just decided that it would be nice to let other devs using this module as well.

1 Like

Oh that was because I messed up the clean up functions. I made the animation connection nil then tried to disconnect :sweat_smile: which resulted in this error:

Players.dthecoolest.PlayerScripts.R6ProceduralAnimations:243: attempt to index nil with 'Disconnect' 

So it’s trying to animate with a destroyed entity. It should be fixed in the latest toolbox version.

Otherwise make sure it’s:

--Make sure it's this
				animationConnection:Disconnect()
				animationConnection = nil
--Rather then the mixed up old one:
				animationConnection = nil
				animationConnection:Disconnect()

For @Tunnells yep it’s a flaw with IKPF I believe even the R15 one has the same problem.

To fix, it is possible to reenable to old Motor6D (commented within the script) and disable the animation connection on jump, however I’m pretty busy so I’ll see when I get back to it.

1 Like

How would I turn this off while sitting? It’s bugging up the custom sit animation I have made.

You could do a check if the player is jumping, and then apply your own animation if so.

There’s a weird bug happening on the legs of my R6 Character.

So I was messing around in the script, doing configurations and stuff. After some time, I noticed that the leg of my character was moving weirdly. I tried to revert the changes in the script and it still happens. When I reinstalled it, the weird movement was still there. I checked every script in my game and it looks like it didn’t affect the movement at all. Then as a last attempt to detecting the problem, I installed it on a new experience and it was there.

I enabled the debug foot position and set the CFrame far away in which it doesn’t interfere and this is what I found. (red is raycast, black is the position of the feet)


Walking on the x-axis is perfectly fine

Walking in-between z & x-axis is slightly odd

Walking on the z-axis is odd (the feet doesn’t even lift off, it just slides)

I don’t know where this bug occurs but my guess is, it comes from the controller thing.

3 Likes

Oh wait actually I found it, nvm, thanks for the plug in tho :smiley:

https://gyazo.com/13bc8e47afcfaf89278b4b6e0f136332

https://gyazo.com/9e3c60d652d367aa6e84ffc0e52a3f2f – I like how the legs run when doing the dash-like move.

https://gyazo.com/3fa0d87f68929ac062458891c63e4c9a

Honestly, I really like it and thinking of implementing it.
It’s not the best but it’s good enough.

Great work! :+1:

1 Like

I really like it but how would I remove or change the character from moving side to side?

All the actual movement is done in the ProceduralAnimation class which creates the goal target for the inverse kinematics as @braveheart882474 is within the video.

Bounce CFrame makes it go up and down.
And the sway controls the rotation side to side, it’s been set to some arbitrary value try playing around with it or removing it entirely.
Modifying the WastCycle will mainly change the timing of when the bounce happens, such as it bounces up when the leg is being raised up.

function ProceduralAnimatorClass:MoveTorso(stepCycle,dt10,rootVelocity)
			local bounceCFrame = CFrame.new(0,self.WalkBounce*math.cos((self.WaistCycle+90+45)*2),0)

			local sway = math.rad(-relv1.X)+0.08*math.cos(self.WaistCycle+90)
			local swayY = 0.1*math.cos(self.WaistCycle)-2*math.rad(relv1.X)
			local swayX = math.rad(relv1.Z)*0.5*self.SwayX
			local goalCF = bounceCFrame*waist1*ANGLES(swayX,swayY,sway):inverse()

For @braveheart882474 sorry for the lack of reply, the legs being funky and not reaching the goal in a nice manner has to do with the inverse kinematics method, it’s iterative and doesn’t generate a 100% solution towards the goal it guesses and tries and doesn’t care if it looks weird or not TL;DR. This is known as an Analytical solution. This is also the reason why it is not compatible with Animations.

You could also reset the C0 of the limbs once in a while in order to make the CCDIK start from the baseline position and reset the rotations locking it in a “weird place”.

Where I learnt the IK method

These concavities are impossible to avoid in a heuristic IK algorithm (read: all of them except Analytic ). However, it is possible to “jump out of” concavities by adding large random offsets to each joint, and then attempting the IK solve again. This is known as “Simulated Annealing”. Implementing this is left as an exercise to the reader.

You can try replacing it with the classic 2 joint and 2 limb inverse kinematics as the code artifically creates an additional limb for R6 to make the R6 pretend it has a knee to raise “Up”.

the code for this is a one liner

function ProceduralAnimatorClass:MoveLegs(stepCycle,dt)
--Current IK method used
			Leg.CCDIKController:CCDIKIterateUntil(footPos,IKTolerance)
1 Like

At this part of the script do I have to remove it entirely? If so does it breaks or not.

It’s the values set that control the swaying, For example try setting

			local sway = math.rad(-relv1.X)+0.08*math.cos(self.WaistCycle+90)

to

			local sway = 0

What do you notice?

I believe it should control the Z axis rotations which is the side to side movement.

1 Like

It’s maybe because of WalkSpeed?

Put it in starter character scripts. So it will work properly!

1 Like

very nice! thank you.
but there is a problem on direction.

no. you can see the problem even on faster speed and lower torso position.

1 Like

i solved with just disabling little things. :smiley:

1 Like